latex3 / latex2e

The LaTeX2e kernel
https://www.latex-project.org/
LaTeX Project Public License v1.3c
1.88k stars 261 forks source link

shellesc: luatex logs `runsystem(<cmd>)...executed` without ending period #1008

Closed muzimuzhi closed 1 year ago

muzimuzhi commented 1 year ago

Brief outline of the bug

When executing a shell command, each of Knuth TeX, pdfTeX, and XeTeX logs runsystem{<cmd>}...executed. with a trailing period after executed. But the emulation in shellesc for luatex doesn't log that period, see line 204. https://github.com/latex3/latex2e/blob/aa89b361a668a483e249839f97e3280dcc316879/required/tools/shellesc.dtx#L194-L211

Minimal example showing the bug

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\usepackage{shellesc}

\begin{document}
\ShellEscape{pwd}
\end{document}

Log file (required) and possibly PDF file

shellesc-trailing-period.pdftex.log shellesc-trailing-period.luatex.log

davidcarlisle commented 1 year ago

@muzimuzhi so it does.

We can of course add . something like

$ diff shellesc.sty~ shellesc.sty
95c95
<        .. ")...(" .. msg .. ")\string\n")
---
>        .. ")...(" .. msg .. ").\string\n")
99c99
<       .. ")...executed\string\n")
---
>       .. ")...executed.\string\n")
103c103
<        .. ")...failed " .. (msg or "") .. "\string\n")
---
>        .. ")...failed. " .. (msg or "") .. "\string\n")

But you still get different messages in fail cases, eg without --shell-escape

luatex then gives

runsystem(pwd)...(Command execution disabled via shell_escape='p').

with a . but pdftex gives

runsystem(pwd)...disabled (restricted).

as I have the luatex message (in msg in the code above) as a Lua string I could try to do string replacements to normalise the messages, but the luatex one is more informative so I'm inclined to leave it.

The difference only matters in l3build or similar (where I see this report orginated) and there Command execution disabled via shell_escape='p' could be normalised to restricted in a custom normalisation step if you wanted to call failing cases and reduce engine log differences.

muzimuzhi commented 1 year ago

Thanks for your detailed comparison for all three cases. I saw the cases but didn't test them. Yes I think for the other two cases the log differences can be normalized by a user-redefined \ShellEscape@Lua or perhaps by l3build itself.

To be honest at first I thought inclusion of runsystem lines in log-based l3build testfiles was a mistake. But then I saw for tests need \showoutput, runsystem lines are not easily avoidable.

davidcarlisle commented 1 year ago

OK thanks for the reply. I'll (just) add dots and not do further normalisation here.