[Tex/LaTex] Emergency stop in plain TeX, pdfTeX, XeTeX and LuaTeX

luatexpdftexplain-texxetex

I'm using <TeX_Engine> -jobname=TEX_TESTING -halt-on-error -interaction=nonstopmode <my_code> to TeX the one-line code A\bye. It does not work. Here are the logs:

Plain TeX:

This is TeX, Version 3.14159265 (TeX Live 2017) (preloaded format=tex
2017.5.23)  5 MAY 2019 17:59
**A\bye

! Emergency stop. <to be read again> 
                   \par  \bye ->\par 
            \vfill \supereject \end  <*> A\bye
          No pages of output.

pdfTeX:

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdftex 2017.5.23)  5 MAY 2019 17:59
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**A\bye

! Emergency stop.
<to be read again> 
                   \par 
\bye ->\par 
            \vfill \supereject \end 
<*> A\bye

!  ==> Fatal error occurred, no output PDF file produced!

XeTeX:

This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xetex 2017.5.23)  5 MAY 2019 17:59
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**A\bye

! Emergency stop.
<to be read again> 
                   \par 
\bye ->\par 
            \vfill \supereject \end 
<*> A\bye

No pages of output.

LuaTeX:

This is LuaTeX, Version 1.0.4 (TeX Live 2017)  (format=luatex 2017.5.23)  5 MAY 2019 17:59
 restricted system commands enabled.
**A\bye

! Emergency stop.
<to be read again> 
\par 
\bye ->\par 
            \vfill \supereject \end 
<*> A\bye

!  ==> Fatal error occurred, no output PDF file produced!

What happened? In TeXShop things work. Is it because of -halt-on-error or -interaction=nonstopmode? I can't get rid of either because I really do not want stopping to happen under any circumstances.

What I need is the simplest valid TeX/XeTeX/LuaTeX code containing a certain string (here it is A). That's it.

Best Answer

From the TeXbook page 23

The ‘**’ is TEX’s way of asking you for an input file name.

Since you want to use TeX interactively rather than processing a file, you have to let TeX know by saying \relax. The error you see comes from the fact that TeX tries to read A\bye as a file name, which involves full expansion of \bye which is defined as

\outer\def\bye{\par\vfill\supereject\end}

which immediately chokes on \par because that is obviously not a legal part of a file name.

So if instead A\bye you say \relax A\bye it works as expected:

This is TeX, Version 3.14159265 (TeX Live 2019) (preloaded format=tex)
**\relax A\bye
[1]
Output written on texput.dvi (1 page, 208 bytes).
Transcript written on texput.log.

You can also type only \relax at the ** prompt and then supply your commands at the * prompt.

This is TeX, Version 3.14159265 (TeX Live 2019) (preloaded format=tex)
**\relax

*A\bye
[1]
Output written on texput.dvi (1 page, 208 bytes).
Transcript written on texput.log.
Related Question