[luatex] os.execute v \write18

David Carlisle d.p.carlisle at gmail.com
Fri Nov 20 14:29:33 CET 2015

Been looking at how easy it is to switch from \write18 to os.execute
(in particular whether you can emulate the former with the latter).
I got so far but wondered if I'd missed a trick that luatex has (it
would not be the first time:-)

Attached is a plain tex file that by default fails to input
\jobname.bbl (as shell escape restricted) but succeeds if
--shell-escape is given

Version B commented out uses bibtex instead of echo and that one
succeeds without --shell-escape assuming the standard texlive
settings of
shell_escape_commands = \

as bibtex is allowed to make the bbl file with restricted shell escape.

That's all good so far, but I'd be happy to take criticism of my lua code:-)

If the \write18 call did not have \immediate in front of it then the
lua ought to be called via \latelua rather than \directlua

(non immediate write18 is probably not used much, but you never know)

Is there any way to detect (in tex or lua) that there is a "pending"
\immediate and to delay the execution if not?

I could of course try to redefine \immediate to set some flag but it's
a fragile thing and hard to redefine as a macro and get reasonably
similar behaviour.

I had wondered if, rather than redefine \write, there would be some
lua callback on writes that I could use to divert the write to a
system call if stream=18,but I think not.

Any suggestions welcome....

Ignoring the issue and always doing the system call immediately is a
possibility: anyone wanting a system call at shipout time could use
\latelua{os.execute()} directly
but it does affect the details of what we can say about cross engine

-------------- next part --------------
A non-text attachment was scrubbed...
Name: write18.tex
Type: application/x-tex
Size: 693 bytes
Desc: not available
URL: <http://tug.org/pipermail/luatex/attachments/20151120/1ecaf7a1/attachment.tex>

More information about the luatex mailing list