# Dependence of \write18 to svg-package

In the following MWE I am experiencing a (to me) very weird dependence of the \write18 command and the svg package.

\documentclass{article}

\RequirePackage{svg}

\begin{document}
\immediate\write18{echo 'test' >> test.txt}

Some content
\end{document}


When compiling the document as provided the file test.txt is created with the proper content. However if I comment out the \usepackage{svg} in my document header this file does not get created.

I am using latexmk with lualatex for compilation (with shell-escape enabled of course) and I even tried compiling the document from the console via lualatex --shell-escape test.tex.
When using pdflatex the problem disappears.

When using the console I see the echo 'test' >> test.txt being printed to the console which indicates (to me) that \write18 is doing its job as one would expect. However (as said above) the file does not get created unless I use the svg package.

I assume that its some \RequirePackage{...} inside the svg package that does the trick.

Does somebody have an explanation to this or may I have encountered a bug in lualatex?

• Behavior confirmed, but see yudal-nkt's answer, which shows how to solve it. Not a bug, just unexpected behavior. – user139954 Jan 14 '18 at 20:32

LuaTeX 0.87 and newer supports write streams up to 256, so \write18 is not treated specially anymore. The LaTeX3 project prepares shellesc package, which is loaded by svg package, to provide a uniform interface to execute external commands.
\documentclass{article}

This package also enables us to use the old syntax \write18{...} in recent LuaTeX, but it should be noted that it is always executed \immediately. If you need to run commands at the time of \shipout, use \DelayedShellEscape instead.