diff options
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/iexec/iexec.dtx | 76 |
1 files changed, 49 insertions, 27 deletions
diff --git a/Master/texmf-dist/source/latex/iexec/iexec.dtx b/Master/texmf-dist/source/latex/iexec/iexec.dtx index 28c2a621365..82182ba0850 100644 --- a/Master/texmf-dist/source/latex/iexec/iexec.dtx +++ b/Master/texmf-dist/source/latex/iexec/iexec.dtx @@ -50,7 +50,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{iexec} %<*package> -[2022-10-10 0.8.1 Inputable Shell Executions] +[2022-10-12 0.9.0 Inputable Shell Executions] %</package> %<*driver> \documentclass{ltxdoc} @@ -105,12 +105,11 @@ Today is % Today is \iexec[log]{date +\%e-\%b-\%Y} % \end{multicols} -% \begin{macro}{\iexec} +% \DescribeMacro{\iexec} % The only command provided by this package is |\iexec| \oarg{options} \marg{cmd}. % Its only mandatory argument \meta{cmd} is the command to be executed % through the terminal shell (bash, or whatever is set as the default one % on your user console). -% \end{macro} % You have to run |pdflatex| (or just |latex|) % with the |--shell-escape| flag @@ -119,7 +118,7 @@ Today is % \section{Options} -% \begin{macro}{quiet} +% \DescribeMacro{quiet} % If you don't want the output to be visible, % use |\phantom\{\iexec{...}}|. % Otherwise, you can use |quiet| option: @@ -137,13 +136,12 @@ I just want to delete some file: %\iffalse %</verb> %\fi -% \end{macro} % In this case, whatever the shell command produces will not be included % into the document. -% \begin{macro}{stdout} -% The output of your code is saved into the file provided as the -% second optional argument of |\iexec| (the default value is |iexec.tmp|): +% \DescribeMacro{stdout} +% The output of your code is saved into the file provided as an +% optional argument of |\iexec| (the default value is |iexec.tmp|): %\iffalse %<*verb> %\fi @@ -158,9 +156,26 @@ Today is \iexec[stdout=date.txt]{date +\%e-\%b-\%Y | tr -d '\\n'}. %</verb> %\fi % The tailing part of the command here removes all ends-of-line. -% \end{macro} -% \begin{macro}{trace} +% \DescribeMacro{stderr} +% The error output of the code is saved into the file provided as an +% optional argument of |\iexec| (by default the error output +% is streamed into |stdout|): +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\documentclass{article} +\usepackage{iexec} +\begin{document} +Today is \iexec[stderr=my.txt]{broken-command}. +\end{document} +\end{verbatim} +%\iffalse +%</verb> +%\fi + +% \DescribeMacro{trace} % The file specified will be deleted right after its usage. If you don't % want this to happen, use |trace| package option: all files will remain % in the directory where they were created. @@ -179,9 +194,8 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. %\iffalse %</verb> %\fi -% \end{macro} -% \begin{macro}{append} +% \DescribeMacro{append} % The stdout produced will be appended to the file specified: %\iffalse %<*verb> @@ -198,9 +212,8 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. %\iffalse %</verb> %\fi -% \end{macro} -% \begin{macro}{log} +% \DescribeMacro{log} % The stdout produced will be printed in \TeX{} log: %\iffalse %<*verb> @@ -215,9 +228,8 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. %\iffalse %</verb> %\fi -% \end{macro} -% \begin{macro}{null} +% \DescribeMacro{null} % The stdout of the command will be sent to |/dev/null|: %\iffalse %<*verb> @@ -232,7 +244,6 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. %\iffalse %</verb> %\fi -% \end{macro} % \StopEventually{} @@ -244,6 +255,8 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. % \changes{v0.5.0}{2022/01/08}{Major bug fixes} % \changes{v0.6.0}{2022/10/09}{Additional options 'log' and 'append'} % \changes{v0.7.0}{2022/10/10}{Additional option 'null'} +% \changes{v0.8.0}{2022/10/11}{Bug fixes} +% \changes{v0.9.0}{2022/10/12}{Additional option 'stderr'} % First, we include a few packages: % \begin{macrocode} @@ -263,6 +276,7 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. /iexec, stdout/.estore in = \iexec@stdout, stdout/.default = iexec.tmp, + stderr/.estore in = \iexec@stderr, trace/.estore in = \iexec@traceit, append/.estore in = \iexec@append, log/.estore in = \iexec@log, @@ -308,6 +322,10 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. \fi\fi% \begingroup% % \end{macrocode} +% Then, start the log from a clean line: +% \begin{macrocode} + \message{^^J}% +% \end{macrocode} % Then, we define a few special chars in order to escape them in the shell % (the full % list of them is in \href{https://ctan.mirror.norbert-ruehl.de/info/macros2e/macros2e.pdf}{macros2e}): @@ -319,33 +337,37 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. % \end{macrocode} % Then, we execute it: % \begin{macrocode} - \ShellEscape{#2 \ifdefined\iexec@append>\fi>\ifdefined\iexec@null/dev/null\else\iexec@stdout\fi}% + \def\iexec@cmd{(#2) + \ifdefined\iexec@append>\fi> + \ifdefined\iexec@null/dev/null\else\iexec@stdout\fi + \space\ifdefined\iexec@stderr2>\iexec@stderr\else2>&1\fi} + \ShellEscape{\iexec@cmd}% % \end{macrocode} % Then, a message is printed to TeX log: % \begin{macrocode} - \message{^^Jiexec: [#2 \ifdefined\iexec@append>\fi>\ifdefined\iexec@null/dev/null\else\iexec@stdout\fi]^^J}% + \message{iexec: [\iexec@cmd]^^J}% \endgroup% % \end{macrocode} % Then, if required, the content of the stdout file will be printed to the log: % \begin{macrocode} \ifdefined\iexec@null\else \ifdefined\iexec@log - \message{^^Jiexec: this is the content of \iexec@stdout:^^J}% + \message{iexec: this is the content of \iexec@stdout:^^J}% \iexec@typeout{\iexec@stdout} - \message{^^J<EOF>^^J}% + \message{<EOF>^^J}% \fi\fi% % \end{macrocode} % Then, include the produced output into the current document: % \begin{macrocode} \ifdefined\iexec@null\else \ifdefined\iexec@quiet - \message{^^Jiexec: Due to 'quiet' option we didn't read + \message{iexec: Due to 'quiet' option we didn't read the content of '\iexec@stdout' (\pdffilesize{} bytes)^^J}% \else% - \message{^^Jiexec: We include the content of + \message{iexec: We include the content of '\iexec@stdout' (\pdffilesize{} bytes)...^^J}% \input{\iexec@stdout}% - \message{^^Jiexec: The content of '\iexec@stdout' + \message{iexec: The content of '\iexec@stdout' was included into the document^^J}% \fi\fi% % \end{macrocode} @@ -353,15 +375,15 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}. % \begin{macrocode} \ifdefined\iexec@null\else \ifiexec@trace% - \message{^^Jiexec: Due to package option 'trace', + \message{iexec: Due to package option 'trace', the file '\iexec@stdout' was not deleted^^J}% \else% \ifdefined\iexec@traceit% - \message{^^Jiexec: Due to 'trace' option, + \message{iexec: Due to 'trace' option, the file '\iexec@stdout' was not deleted^^J}% \else% \ShellEscape{rm \iexec@stdout}% - \message{^^Jiexec: The file '\iexec@stdout' was deleted^^J}% + \message{iexec: The file '\iexec@stdout' was deleted^^J}% \fi% \fi\fi% \endgroup |