(Edit: How to do file system operations and binary execution with LuaTeX in an OS-independent manner? I had written a set of macros for pdfTeX to do this using the \write18
command. These macros were meant to be usable under both Windows and Linux, giving some "higher level" control. Now I wanted the macros to also support LuaTeX. My first experiments were unsuccessful, however. Trying to reduce the problem by omitting all macros and executing LuaTeX on the command line mislead the focus to an unimportant problem before I found a solution some days later.)
In a minimal testing environment (see Minimal Testing Environment For LuaMetaTeX) I can do the initial memory dump
luatex --ini ./plain.tex \dump
and then I would expect the following command to list the directory:
luatex --fmt=./plain.fmt --shell-escape \directlua {os.execute ("dir")}\end
but it just tells me:
This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
system commands enabled.
No pages of output.
Transcript written on texput.log.
So how do I execute system commands under LuaTeX as it is possible under pdfTeX with \write18
?
luatex --shell-escape '\directlua {os.execute ("dir")}\end'
lists all the files in the directory for me (I need the single quotes to protect the\
from the commandline shell)! I can't find file `''.
whereas it does indeed work for me having exchanged double and single quotes:luatex --fmt=./plain.fmt --shell-escape "\directlua {os.execute ('dir')}\end"
. That's fine, yet it looks as if LuaTeX's behavior were a bit unpredictable across installations.luatex --ini ./plain.tex "\dump"
works whereasluatex --ini ./plain.tex '\dump'
produces a 1 page, 180 bytesplain.dvi
output.luatex --help
doesn't mention as syntax-conforming any quoting of remaining commands to be processed by LuaTeX.