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).

\message{\meaning\foo ab}



i.e., the same as


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

  • 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

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.


function  (s)
snew, n =  string.gsub(s,"\string\r","^^M")
return snew

\message{\meaning\foo ab}
\immediate\write\x{\meaning\foo ab}


On the terminal you get

ab )o:->\

but in the file you get:

$ cat nnl.out

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: 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).

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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