Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Contrarily to pdfTeX and XeTeX, which send ^^M to the terminal for the character 13, LuaTeX sends the character 13 itself. This garbles the output of my terminal (bash under Ubuntu 10.04).

\edef\foo{\string\^^M}
\message{\meaning\foo ab}

gives

abcro:->\

i.e., the same as

macro:->\
ab 

but smashed into a single line. How can I tell LuaTeX to output ^^M instead?

share|improve this question
    
This seems like a bug. –  egreg Jul 31 '12 at 19:39
    
@egreg I had started to submit a bug report, but then had doubts on whether it was a bug or simply that I should change how ^^M was displayed in my particular terminal. I'll submit a bug report. –  Bruno Le Floch Jul 31 '12 at 20:01
    
Bug report submitted. –  Bruno Le Floch Jul 31 '12 at 20:10
add comment

2 Answers 2

up vote 10 down vote accepted

As @egreg says, it looks like a bug to me. For writing to files you can modify a lua callback but unfortunately the callback (as documented) is not called when writing to the terminal.

\edef\foo{\string\^^M}

{\catcode`\^=12
\directlua{
callback.register(
"process_output_buffer",
function  (s)
snew, n =  string.gsub(s,"\string\r","^^M")
return snew
end)
}}


\message{\meaning\foo ab}
\newwrite\x
\immediate\openout\x=nnl.out
\immediate\write\x{\meaning\foo ab}

\stop

On the terminal you get

ab )o:->\

but in the file you get:

$ cat nnl.out
macro:->\^^Mab
share|improve this answer
    
I'll submit a bug report. –  Bruno Le Floch Jul 31 '12 at 20:01
add comment

From LuaTeX Reference, beta 0.70.1, section 2.3 UNICODE text support:

Output to the terminal uses ^^ notation for the lower control range (c < 32), with the exception of ^^I, ^^J and ^^M. These are considered 'safe' and therefore print-as-is.

And in the manual are the terminal/log explicitely excluded for process_output_buffer:

4.1.3.2 process_output_buffer (0.43)
[…] It is only called for output to an actual file (that is, excluding the log, the terminal, and \write18 calls).

share|improve this answer
    
Ah, so that is not a bug, rather a bad feature. However, it leads to a garbled terminal output, so a work-around would be useful. Do you agree with David that there is no appropriate callback for this? –  Bruno Le Floch Jul 31 '12 at 21:00
3  
Not really, the output of the terminal/log is messed up anyway with much loss of information (catcodes, line breaks, &hellip;). If you are debugging such stuff, then you can use a decent editor &mdash; the data are not lost, even less shows me the ^^M as control character. Not having a callback has its advantages. The user knows, nobody has messed up with the output, showing beautiful things while doing malicious things. –  Heiko Oberdiek Jul 31 '12 at 21:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.