# Does the lualatex shell enable behavior differ from pdflatex on purpose?

I am trying to use TikzEdt, an editor for TikZ graphics. For some tasks TikZ needs to call other commands so I tried to enable this by the parameter --shell-escape passed to lualatex (on Windows, MiKTeX 2.9). Strangely this fails to enable the feature. After some fiddling around it turns out that it even fails with this MWE:

    \documentclass{standalone}

\begin{document}
\write18{echo SHELL ENABLED}
\end{document}


TikzEdt appends the switch and calls lualatex test.tex --shell-escape which does not seem to work. The same command with pdflatex works nicely. It turns out that other than in pdflatex the order of arguments seem to play a role in lualatex, lualatex --shell-escape test.tex runs nicely. Unfortunately TikzEdt only allows to append switches not insert switches. Is this a bug in lualatex or is TikzEdt using a wrong assumption?

-
If I'm not mistaken, everything that goes after the filename is treated as a command. As the --help flag gives us the hint, "Any remaining COMMANDS are processed as pdfTeX input, after TEXNAME is read. If the first line of TEXNAME is %&FMT, and FMT is an existing .fmt file, use it. Else use NAME.fmt, where NAME is the program invocation name, most commonly pdftex." – Paulo Cereda Feb 4 '13 at 13:42
By the way, my test was consistent here with both pdflatex and lualatex (I got the same results), so flags really should come before the filename. :) – Paulo Cereda Feb 4 '13 at 13:43
Probably it is another MiKTeX feature; commandline parsing is not done by support code from the Web2c system (and its equivalent in MiKTeX), except probably for LuaTeX. – Khaled Hosny Feb 4 '13 at 14:21

Let's try a simple document test.tex; the package pdftexcmds is loaded in order to have \pdf@shellescape available with all engines.

\documentclass{article}
\usepackage{pdftexcmds}
\makeatletter
\count@=\pdf@shellescape
\showthe\count@
\makeatother

\begin{document}
Ciao
\end{document}


Here's what happens with

• pdflatex test
• pdflatex test --shell-escape
• lualatex test
• lualatex test --shell-escape
• xelatex test
• xelatex test --shell-escape

The execution stops because of \showthe, showing

> 2.
l.5 \showthe\count@


in all six invocations (TeX Live 2012 on Mac OS X, but I don't think it's different with other platforms).

If we put --shell-escape at its proper place, the execution of any of

• pdflatex --shell-escape test
• lualatex --shell-escape test
• xelatex --shell-escape test

stops showing

> 1.
l.5 \showthe\count@


This means that the setting of --shell-escape can be done only in "infix notation" and that the option has no effect if postfixed.

As kindly as usual, Paulo Cereda confirms that, on MiKTeX, options can be specified after the file name for pdftex and xetex, but not for luatex. As the most common syntax format on other systems is with "infix" options, my opinion is that TikZEdt is wrong in its assumptions.

-
Hmm, this seems to be different here. Your example document stops and shows \showthe\count@ with both, lualatex --shell-escape example and pdflatex --shell-escape example on MikTeX 2.9. I really dislike these strange incompatibilities. – Alexander Feb 4 '13 at 14:35
@Alexander My opinion is that it's best to stick to the most common "cross platform" way of doing things. For instance, MiKTeX adopted --shell-escape after having used --enable-write18 for some years. – egreg Feb 4 '13 at 14:42
Yes egreg, I absolutely agree. I looked up the POSIX guidelines and they state that option processing stops after the first command, so according to what you observe. – Alexander Feb 4 '13 at 15:03
@mafp Yes. I should've made it clearer. – egreg Feb 4 '13 at 15:07

the syntax of luatex (lualatex) is

Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]
or: luatex --lua=FILE [OPTION]... \FIRST-LINE
or: luatex --lua=FILE [OPTION]... &FMT ARGS


--shell-escape is an option the reason why it must be before the TEXNAME[.tex]

-