I create in my folder a file "blub.temp" and then tried out the following
\documentclass{article} \usepackage[T1]{fontenc} \usepackage{shellesc} %correct small bug in shellesc: \protected\def\ShellEscape{\immediate\write18 } \begin{document} \ShellEscape{kpsewhich article.cls >> blub.temp} \immediate\write18{kpsewhich book.cls >> blub.temp} \end{document} When I compile this (pdflatex on miktex, texlive 2015, texlive 2016) without shell-escape I see messages like this in the log-file
runsystem(kpsewhich book.cls >> blub.temp)...executed safely (allowed). But blub.temp has no content.
When I compile with --shell-escape I see messages like
runsystem(kpsewhich book.cls >> blub.temp)...executed. and blub.temp contains the both pathes.
How can it be that the command is executed but does nothing when --shell-escape is not used? Can one correct this?
Edit
As confirmed on the texlive list, redirections (>, >>) don't work in restricted mode. So the question is if there is any other way to catch the output of kpsewhich (without pipes or --shell-escape) ...
kpsewhichis in the list of programs allowed in the restricted shell; but in this case it is not allowed to write files, as far as I can see. I guess that Karl Berry is the one who can answer this; probably output redirection is not allowed in the restricted shell.shellescto be found? At least for me, CTAN search doesn't find it. This is weird because it is clearly in TeX Live. Is there a way to find these things on CTAN? I told it to search everything, including file names.