Makefile/latexmk 删除特殊字符问题

Makefile/latexmk dropping special chars issue

问题

这是我的 Makefile:

SRC=src/main.tex
DST_DIR=bin

ENGINE=latexmk
FLAGS=-synctex=1 --interaction=nonstopmode -file-line-error -xelatex -cd -outdir=../$(DST_DIR)

all:
    $(ENGINE) $(FLAGS) -usepretex="\def\foo{1}\def\bar{0}" -jobname="all" $(SRC)

当我 运行 目标 all,

$ make all
latexmk -synctex=1 --interaction=nonstopmode -file-line-error -xelatex -cd -outdir=../bin -usepretex="\def\foo{1}\def\bar{1}" -jobname="all" src/main.tex
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76.
Latexmk: Changing directory to 'src/'
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'main.tex'
------------
Run number 1 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf -synctex=1 --interaction=nonstopmode -file-line-error -recorder --jobname="all" -output-directory="<my-project-dir>/bin"  "deffoo1defbar1\input{main.tex}"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `deffoo1defbar1'.
<to be read again>
                   \let
<*> deffoo1defbar1\input
                        {main.tex}
(Press Enter to retry, or Control-Z to exit)
Please type another input file name
! Emergency stop.
<to be read again>
                   \let
<*> deffoo1defbar1\input
                        {main.tex}

你可以看到 pretex \def\foo{1}\def\bar{1} 被正确传送到 latexmk,但在执行 xelatex 命令时更改为 deffoo1defbar1,即忽略反斜杠和大括号。

这个问题的可能问题和解决方案是什么?

到目前为止我尝试了什么

$ latexmk -synctex=1 --interaction=nonstopmode -file-line-error -xelatex -cd -outdir=../bin -usepretex="\def\foo{1}\def\bar{1}" -jobname="all" src/main.tex

额外的神秘结果

我有项目 A 的 Makefile A,项目 B 的 Makefile B,Makefile 中的两个 latexmk 命令都使用带有反斜杠和大括号的前缀。我还有两个 Windows 10 设备 X 和 Y。当我在我的设备上 运行 Makefiles...

我不知道为什么只有 Makefile A 不能只在设备 X 上工作。

我刚刚解决了这个问题;问题出在安装 git 时的“可选 Unix 工具”。 git 在设备 X 上 安装了 可选的 Unix 工具,在设备 Y 上 没有 工具。

我在设备 X 上重新安装了 git,没有工具,脚本成功了。