为什么这个害羞的输入会失败?

为什么这个害羞的输入会失败?

我正在尝试测试线程答案这里关于在 LaTeX 中输入多个文件但我收到以下关于文件为空的错误。我需要有 documentclass文章根据文档应该没问题这里

\documentclass{article}

\usepackage{bashful} % https://tex.stackexchange.com/a/13943/13173

\begin{document}

%https://tex.stackexchange.com/a/13943/13173
\bash[stdoutFile=inputs_ls.tex]
{ ls *.jpg | sort -n } 
\END
\input{inputs_ls.tex}

\end{document}

输出

L10: File inputs_ls.texwas empty
after EOF
L10: bashStdout :=
\bashStdout 
L10: Closing file inputs_ls.tex
L10: Defining macro for the contents of the standard error file
L10: Opened file test.input.bash.stderr
L10: File inputs_ls.texwas empty
! Undefined control sequence.
<write> ...nputlineno : bashStderr :=
\bashStderr 

l.10 \END
         ^^M
? 

再次测试 egreg 的解决方案

使用绝对路径

\documentclass{article}

\usepackage{bashful} % https://tex.stackexchange.com/a/13943/13173

\begin{document}

%https://tex.stackexchange.com/a/13943/13173
\bash[stdoutFile=inputs_ls.tex]
ls /home/masi/Documents/Images/*.jpg | sort -n 
\END
\input{inputs_ls.tex}

\end{document}

输出

\everyMPtoPDFconversion=\toks18
)
\c@lstlisting=\count103
\openout3 = `test.input.bash.sh'.

runsystem(bash -c "bash test.input.bash.sh >inputs_ls.tex 2>test.input.bash.std
err || echo $? >test.input.bash.exitCode")...disabled (restricted).

\openout3 = `test.input.bash.sh'.


L10: I will now print the contents of file test.input.bash.stderr (if found)
L10: File test.input.bash.stderr was empty
L10: Proceeding as usual
L10: Checking whether any listings are required
L10: Nothing has to be listed
L10: Defining macro for the contents of the standard output file
L10: Opened file inputs_ls.tex
L10: File inputs_ls.texwas empty
after EOF
L10: bashStdout :=
\bashStdout

L10: Closing file inputs_ls.tex
L10: Defining macro for the contents of the standard error file
L10: Opened file test.input.bash.stderr
L10: File inputs_ls.texwas empty
! Undefined control sequence.
<write> ...nputlineno : bashStderr :=
\bashStderr

l.10 \END
         ^^M
? X

Here is how much of TeX's memory you used:
 3434 strings out of 493013
 48381 string characters out of 6133327
 110335 words of memory out of 5000000
 6992 multiletter control sequences out of 15000+600000
 3640 words of font info for 14 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 33i,0n,37p,233b,219s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
PDF statistics:
 0 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

运行命令pdflatex -shell-escape ...,它起作用了。没有错误。已确认。

TeXLive:2016
操作系统:Debian 8.5
引擎:pdflatex,也测试了 xelatex

答案1

因为{ ls *.jpg | sort -n }对于 shell 来说这是无效的语法。

\bash[stdoutFile=inputs_ls.tex]
ls *.jpg | sort -n
\END

相关内容