带有 pdflatex -jobname 的诡计系统*

Guile scheme system* with pdflatex -jobname

我正在尝试从诡计文件中调用 pdflatex。这是我正在使用的 Guile 命令:

(system*
 "cat" "foo.txt" "|" "pdflatex" "-jobname" "\"bar\"")

这是我在 运行 更新文件后得到的错误:

cat: invalid option -- 'j'
Try 'cat --help' for more information.

如果我 运行 来自 bash shell 的命令,它 运行 正常。

cat foo.txt | pdflatex -jobname "bar"

-jobnamepdflatex 的正确命令,但 system* 似乎有问题。

我正在使用 (GNU Guile) 2.2.4 和 pdfTeX 3.14159265-2.6-1.40.20。

使用 system,而不是 system*。它采用单个字符串作为参数,并使用 shell 执行它,这将执行所需的管道。

(system "cat foo.txt | pdflatex -jobname 'bar'")

system* 不使用 shell。正如 manual 解释的那样:

system* is similar to system, but accepts only one string per-argument, and performs no shell interpretation. The command is executed using fork and execlp. Accordingly this function may be safer than system in situations where shell interpretation is not required.

请注意,您的命令是 Useless use of cat,因为 pdflatex 将文件名作为参数。您可以使用 system* 直接执行它。

(system* "pdflatex" "-jobname" "bar" "foo.txt")

此外,当您使用 system* 时,您不需要在 bar 周围添加额外的引号;因为它不使用 shell,所以它不解析特殊字符。