Open Arinerron opened 1 year ago
When the input filename has spaces, like spaces in filename.tex
, \jobname
is already quoted ("spaces in filename"). But in various places ifplatform
adds another pair of quotes. This resulted in executing commands with extra operand, like in
runsystem(uname -s > ""REDACTED".w18")...executed.
https://github.com/wspr/will2e/blob/a6c00f55826fbeb365d2018544536759a9b45dc7/ifplatform/ifplatform.dtx#L246 https://github.com/wspr/will2e/blob/a6c00f55826fbeb365d2018544536759a9b45dc7/ifplatform/ifplatform.dtx#L376
You can use expl3
functions \sys_if_platform_unix:TF
and \sys_if_platform_windows:TF
to replace ifplatform
, also see #5.
If ifplatform
is loaded by another package, like minted
, here's an emulation of \ifwindows
needed by minted
.
\documentclass{article}
\ExplSyntaxOn
% pretend ifplatform is loaded
\tl_const:cn {ver@ifplatform.sty} {0000-00-00}
\newif\ifwindows
\sys_if_platform_windows:TF {\windowstrue} {\windowsfalse}
\ExplSyntaxOff
\usepackage{minted}
\begin{document}
\begin{minted}{tex}
$a + b = c^2$
\end{minted}
content
Thank you @muzimuzhi I had the same error and your workaround fixed it!
@wspr Consider fixing this issue? On Linux, this patch fixes it for me:
--- ifplatform.sty 2024-03-04 04:45:05.830042206 +0700
+++ /usr/share/texmf-dist/tex/latex/ifplatform/ifplatform.sty 2024-03-04 04:46:58.536711651 +0700
@@ -51,17 +51,17 @@
\else
\IfFileExists{nul:}{\@ip@nix@false}{\@ip@nix@true}
\IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
- \edef\ip@windows@echo@test{echo \string# > "\ip@file"}
+ \edef\ip@windows@echo@test{echo \string# > \ip@file}
\def\ip@backupplan{%
\IfFileExists{\ip@file}{%
\PackageWarningNoLine{ifplatform}{^^J \space\space\space
- Please delete the file "\ip@file" and try again%
+ Please delete the file \ip@file and try again%
}%
\ip@cantdecide
}{%
\ShellEscape{\ip@windows@echo@test}%
\IfFileExists{\ip@file}{%
- \ShellEscape{del "\ip@file"}%
+ \ShellEscape{del \ip@file}%
\windowstrue
}{%
\@ip@nix@true
@@ -88,9 +88,9 @@
\def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
\if@ip@nix@\ifshellescape
\ifwindows\else
- \ShellEscape{uname -s > "\ip@file"}
+ \ShellEscape{uname -s > \ip@file}
\CatchFileDef\@tempa{\ip@file}{}
- \ShellEscape{rm -- "\ip@file"}
+ \ShellEscape{rm -- \ip@file}
\edef\@tempa{\expandafter\zap@space\@tempa\@empty}
\def\@tempb{Linux}
\ifx\@tempa\@tempb
Assume \jobname
is also quoted on Windows and Mac etc. if it has a space, this should be safe
Unfortunately I can't share reproduction steps, but thought I'd note there seems to be some kind of argument escaping issue:
The "REDACTED" filename has spaces in it which probably has something to do with it. I never experienced this issue till I added "
-shell-escape
" arg tolatexmk
in our build process.