On 11/20/2015 2:29 PM, David Carlisle wrote:
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 = \
bibtex,bibtex8,\
extractbb,\
kpsewhich,\
makeindex,\
mpost,\
repstopdf,\
as bibtex is allowed to make the bbl file with restricted shell escape.
these all look immediate to me
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?
actually the immediate issue was why i kept the 18 as special case
now, personally i never needed a non-immediate and os.execute is like
that (unless wrapped in latelua) so that is why dropping 18 is not that
big a deal
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.
the problem with immediate is that it is not really a prefix like
\global or \protected or ... but part if the extension loop and there it
is just a flag and not a state (latelua is done elsewhere) .. in fact
immediate is some kind of no-op otherwise (i considered making it some
state but then we have rather tricky reset / expansion interactions so i
rejected that)
so, adding extra \immediate overhead and complexity for the sake of
execute is not going to happen
(some time ago i played more than a day with that conceptual mess and in
the end reverted all)
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.
no
Any suggestions welcome....
just provide two commands:
\immediatesystemcommand{...}
\delayedsystemcommand {...}
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
right
but it does affect the details of what we can say about cross engine
compatibility.
so make a specific execute command and implement it different for
different engines
write18 was a strange animal anyway
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------