Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua-implementation of pdf@shellescape should be reconsidered. #20

Closed
u-fischer opened this issue Feb 21, 2017 · 2 comments
Closed

lua-implementation of pdf@shellescape should be reconsidered. #20

u-fischer opened this issue Feb 21, 2017 · 2 comments

Comments

@u-fischer
Copy link
Contributor

Starting from a question on tex.sx
https://tex.stackexchange.com/questions/354830/lualatex-compilation-fails-when-sorting-text-using-luacode
the following minimal example was created. It fails with the error

)...xlive/2016/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua:195: standard outpu
t file is closed

The error is caused by the faulty definition of sort_tdo which doesn't restore correctly the output handler but also leads to the question if the lua implementation of \pdf@shellescape in oberdiek.pdftexcmds.lua should be reconsidered to use a less fragile method.


\documentclass{article}

\directlua{
   function sort_tdo (jobname)
    file=io.open(jobname.."sorted", "w")
    % zz=io.output() %store output
    io.output(file)
    io.close(file)
    % io.output(zz)  %restore output
   end
}

\directlua{
 function shellescape()
  if os.execute then
   tex.write(os.execute())
  end
end}



\directlua{sort_tdo("\jobname.tdo")}

\makeatletter 
%\def\pdf@shellescape{\directlua{tex.sprint(status.shell_escape .. " ")}} %works
\def\pdf@shellescape{\directlua{shellescape()}}% breaks
\ifnum\pdf@shellescape>0 %
  \show\x
\fi
\begin{document}
\end{document}
@davidcarlisle
Copy link
Member

davidcarlisle commented Feb 21, 2017 via email

@davidcarlisle
Copy link
Member

the new pdf@shellescape is in the last ctan release, thanks for the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants