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

lualatex/xelatex: handling of stderr when using pipes #648

Closed
mrpiggi opened this issue Oct 22, 2020 · 5 comments
Closed

lualatex/xelatex: handling of stderr when using pipes #648

mrpiggi opened this issue Oct 22, 2020 · 5 comments
Assignees
Projects
Milestone

Comments

@mrpiggi
Copy link

mrpiggi commented Oct 22, 2020

Hi,
some context first. I am the developer of the LaTeX package svg which uses Inkscape CLI for automated conversion and import of SVG graphics into LaTeX documents. As Inkscape changed it's CLI from 0.9x to 1.0 I was encouraged to build an automatic version detection. Therefore I call inkscape -V during a LaTeX run through a pipe in order to read the returned string.

I recently discovered a problem reading from a pipe when both stdout and stderr are involved. This issue actually emerged as Inkscape v1.0.1 CLI currently uses stdout and stderr when returning inkscape -V. I already reported this issue.

However, I wanted to remark that MiKTeX has problems with handling stderr when reading pipes. First the MWE

\listfiles
\documentclass{minimal}
\usepackage[T1]{fontenc}
\begin{document}
\makeatletter
\@makeother\|%
\@makeother\&%
\everyeof{\noexpand}%

\edef\pipenormal{\@@input|"echo STDOUT && echo STDERR >&2 " }%
normal: \texttt{\pipenormal}

\edef\piperedirect{\@@input|"echo STDOUT && 2>&1 echo STDERR >&2 " }%
redirect: \texttt{\piperedirect}

\end{document}

The macro \pipenormal reads through a pipe and should expand to the message of stdout whereas \piperedirect redirects stderr to stdout and should expand to both messages. I checked this with TeX Live and it works as intended with all different formats (pdflatex, lualatex, xelatex). By contrast, MiKTeX generates different results for all three formats. Those are:

normal redirected
expected STDOUT STDOUT STDERR
pdflatex STDOUT STDERR STDOUT STDERR
lualatex STDOUT STDERR DOUT DERR
xelatex STDERR STDERR
@edocevoli
Copy link
Member

edocevoli commented Oct 23, 2020

I would recommend that you fix the expectations. Because echo STDOUT && echo STDERR >&2, on Windows, outputs:

STDOUT
STDERR

So the table must look like this:

normal redirected
expected STDOUT STDERR STDOUT STDERR
pdflatex STDOUT STDERR STDOUT STDERR
lualatex STDOUT STDERR DOUT DERR
xelatex STDERR STDERR

@edocevoli edocevoli changed the title Handling of stderr when using pipes xelatex: handling of stderr when using pipes Oct 23, 2020
@edocevoli edocevoli changed the title xelatex: handling of stderr when using pipes lualatex/xelatex: handling of stderr when using pipes Oct 23, 2020
@mrpiggi
Copy link
Author

mrpiggi commented Oct 23, 2020

echo STDOUT && echo STDERR >&2, on Windows, outputs:

STDOUT
STDERR

As well as Linux does. My expectations came from the behavior of TeX Live where stderr is suppressed/gobbled. But I'm totally fine with your call. Many thanks in avdance.

@edocevoli edocevoli self-assigned this Oct 23, 2020
@edocevoli edocevoli added this to To do in What's next via automation Oct 23, 2020
@edocevoli edocevoli moved this from To do to In progress in What's next Oct 23, 2020
@edocevoli edocevoli added this to the 20.11 milestone Oct 23, 2020
edocevoli added a commit that referenced this issue Oct 23, 2020
@mrpiggi
Copy link
Author

mrpiggi commented Oct 23, 2020

Many thanks!

@edocevoli
Copy link
Member

Thank you, this has been fixed. Please get the latest updates.

What's next automation moved this from In progress to Done Nov 1, 2020
@mrpiggi
Copy link
Author

mrpiggi commented Nov 3, 2020

Works like expected. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
What's next
  
Done
Development

No branches or pull requests

2 participants