texlive[64771] Master/texmf-dist: iexec (21oct22)

commits+karl at tug.org commits+karl at tug.org
Fri Oct 21 21:39:30 CEST 2022


Revision: 64771
          http://tug.org/svn/texlive?view=revision&revision=64771
Author:   karl
Date:     2022-10-21 21:39:30 +0200 (Fri, 21 Oct 2022)
Log Message:
-----------
iexec (21oct22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/iexec/iexec.pdf
    trunk/Master/texmf-dist/source/latex/iexec/iexec.dtx
    trunk/Master/texmf-dist/tex/latex/iexec/iexec.sty

Modified: trunk/Master/texmf-dist/doc/latex/iexec/iexec.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/iexec/iexec.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/iexec/iexec.dtx	2022-10-21 19:39:04 UTC (rev 64770)
+++ trunk/Master/texmf-dist/source/latex/iexec/iexec.dtx	2022-10-21 19:39:30 UTC (rev 64771)
@@ -50,12 +50,13 @@
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{iexec}
 %<*package>
-[2022-10-15 0.9.1 Inputable Shell Executions]
+[2022-10-21 0.10.1 Inputable Shell Executions]
 %</package>
 %<*driver>
 \documentclass{ltxdoc}
 \usepackage[tt=false, type1=true]{libertine}
 \usepackage{microtype}
+\usepackage[dtx]{docshots}
 \usepackage{iexec}
 \usepackage{href-ul}
 \PageIndex
@@ -81,29 +82,16 @@
 % This package helps you execute shell commands right from the
 % document and then put their output to the document:
 %
-% \begin{multicols}{2}
-% \setlength{\parskip}{0pt}
-% \small
-% \raggedcolumns
-%\iffalse
-%<*verb>
-%\fi
-\begin{verbatim}
-\documentclass{article}
-\usepackage{iexec}
-\begin{document}
-Today is
-  \iexec{date +\%e-\%b-\%Y}
-\end{document}
-\end{verbatim}
-%\iffalse
-%</verb>
-%\fi
-%
-% \columnbreak
-%
-% Today is \iexec[log]{date +\%e-\%b-\%Y}
-% \end{multicols}
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage{iexec}
+% \usepackage[paperwidth=3in]{geometry}
+% \pagestyle{empty}
+% \begin{document}
+% Today is \textbf{%
+%   \iexec{date +\%e-\%b-\%Y}}
+% \end{document}
+% \end{docshot}
 
 % \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
@@ -117,7 +105,8 @@
 
 % \section{Options}
 
-% \DescribeMacro{quiet} If you don't want the output to be visible,
+% \DescribeMacro{quiet}
+% If you don't want the output to be visible,
 % use |\phantom\{\iexec{...}}|.
 % Otherwise, you can use |quiet| option:
 %\iffalse
@@ -124,12 +113,8 @@
 %<*verb>
 %\fi
 \begin{verbatim}
-\documentclass{article}
-\usepackage{iexec}
-\begin{document}
 I just want to delete some file:
 \iexec[quiet]{rm -f foo.txt}
-\end{document}
 \end{verbatim}
 %\iffalse
 %</verb>
@@ -137,17 +122,14 @@
 % In this case, whatever the shell command produces will not be included
 % into the document.
 
-% \DescribeMacro{stdout} The output of your code is saved into the file provided as an
+% \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
 \begin{verbatim}
-\documentclass{article}
-\usepackage{iexec}
-\begin{document}
 Today is \iexec[stdout=date.txt]{date +\%e-\%b-\%Y | tr -d '\\n'}.
-\end{document}
 \end{verbatim}
 %\iffalse
 %</verb>
@@ -154,7 +136,8 @@
 %\fi
 % The tailing part of the command here removes all ends-of-line.
 
-% \DescribeMacro{stderr} The error output of the code is saved into the file provided as an
+% \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
@@ -161,17 +144,14 @@
 %<*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
+% \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.
 % It's possible to turn tracing on globbaly, for the entire document, using
@@ -190,7 +170,8 @@
 %</verb>
 %\fi
 
-% \DescribeMacro{append} The stdout produced will be appended to the file specified:
+% \DescribeMacro{append}
+% The stdout produced will be appended to the file specified:
 %\iffalse
 %<*verb>
 %\fi
@@ -207,49 +188,47 @@
 %</verb>
 %\fi
 
-% \DescribeMacro{log} The stdout produced will be printed in \TeX{} log:
+% \DescribeMacro{log}
+% The stdout produced will be printed in \TeX{} log:
 %\iffalse
 %<*verb>
 %\fi
 \begin{verbatim}
-\documentclass{article}
-\usepackage{iexec}
-\begin{document}
 \iexec[log]{echo 'Hello, \\LaTeX!'}
-\end{document}
 \end{verbatim}
 %\iffalse
 %</verb>
 %\fi
 
-% \DescribeMacro{null} The stdout of the command will be sent to |/dev/null|:
+% \DescribeMacro{null}
+% The stdout of the command will be sent to |/dev/null|:
 %\iffalse
 %<*verb>
 %\fi
 \begin{verbatim}
-\documentclass{article}
-\usepackage{iexec}
-\begin{document}
 \iexec[null]{rm some-file.txt}
-\end{document}
 \end{verbatim}
 %\iffalse
 %</verb>
 %\fi
 
+% \DescribeMacro{ignore}
+% By default, we report an error if exit code is not equal to zero. You can suppress
+% this with |ignore| option:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\iexec[ignore]{broken-command}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
 % \StopEventually{}
 
 % \section{Implementation}
 
-% \changes{v0.2.0}{2021/07/10}{Initial version}
-% \changes{v0.4.0}{2021/08/01}{Runtime verification for --shell-escape option}
-% \changes{v0.4.1}{2021/08/08}{Options trace, stdout, and quiet added}
-% \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 \href{https://ctan.org/pkg/shellesc}{shellesc} package, which
 % we use to execute shell commands:
 %    \begin{macrocode}
@@ -267,6 +246,9 @@
 %    \end{macrocode}
 
 % Then, we prepare to parse the options of |\iexec| command:
+% \changes{v0.10.0}{2022/10/19}{The option "ignore" suppresses the checking of "iexec.ret" value.}
+% \changes{v0.7.0}{2022/09/25}{The option "append" was introduced --- if it's turned on, stdout will be appended to the file, instead of rewriting it (this is how it was before).}
+% \changes{v0.7.0}{2022/09/25}{The option "log" was introduced, to turn on log/debug messages in TeX log (they were all visible always, which was sometimes annoying. Also, this option enables printing of the entire content of stdout to the log too (this may be pretty convenient for debugging).}
 %    \begin{macrocode}
 \RequirePackage{pgfkeys}
 \makeatletter\pgfkeys{
@@ -280,6 +262,7 @@
   log/.store in = \iexec at log,
   null/.store in = \iexec at null,
   quiet/.store in = \iexec at quiet,
+  ignore/.store in = \iexec at ignore,
   stdout
 }\makeatother
 %    \end{macrocode}
@@ -307,9 +290,12 @@
 % \begin{macro}{\iexec}
 % Then, we define |\iexec| command.
 % It is implemented with the help of |\ShellEscape| from |shellesc| package:
+% \changes{v0.10.0}{2022/10/19}{The file "iexec.ret" is reused for all scripts.}
 %    \begin{macrocode}
-\makeatletter\newcommand\iexec[2][]{%
-  \begingroup
+\makeatletter
+\newread\iexec at retfile
+\newcommand\iexec[2][]{%
+  \begingroup%
     \pgfqkeys{/iexec}{#1}%
 %    \end{macrocode}
 % First, we verify that |latex| is running with |--shell-escape| option, since without
@@ -323,7 +309,9 @@
 %    \end{macrocode}
 % Then, start the log from a clean line:
 %    \begin{macrocode}
-      \message{^^J}%
+      \ifdefined\iexec at log%
+        \message{^^J}%
+      \fi%
 %    \end{macrocode}
 % Then, we define a few special chars in order to escape them in the shell
 % (the full
@@ -335,36 +323,60 @@
       \let\}\@charrb%
 %    \end{macrocode}
 % Then, we execute it:
+% \changes{v0.10.0}{2022/10/19}{The ability to track exit code was added. Now, the code is saved into "iexec.ret" file, which is then read and checked for zero value.}
+% \changes{v0.8.0}{2022/10/05}{The option "null" was introduced, allowing redirection of stdout to "/dev/null". Doesn't work on Windows, though.}
+% \changes{v0.9.0}{2022/10/15}{The option "stderr" was introduced, allowing redirection of stderr to a file. Without this option specified, stderr will go to stdout.}
 %    \begin{macrocode}
       \def\iexec at cmd{(#2)
         \ifdefined\iexec at append>\fi>
         \ifdefined\iexec at null/dev/null\else\iexec at stdout\fi
-        \space\ifdefined\iexec at stderr2>\iexec at stderr\else2>&1\fi}
+        \space\ifdefined\iexec at stderr2>\iexec at stderr\else2>&1\fi
+        \ifdefined\iexec at ignore\else; echo $? >iexec.ret\fi}
       \ShellEscape{\iexec at cmd}%
 %    \end{macrocode}
 % Then, a message is printed to TeX log:
 %    \begin{macrocode}
-      \message{iexec: [\iexec at cmd]^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: [\iexec at cmd]^^J}%
+      \fi%
     \endgroup%
 %    \end{macrocode}
 % Then, if required, the content of the stdout file will be printed to the log:
 %    \begin{macrocode}
-    \ifdefined\iexec at null\else
-    \ifdefined\iexec at log
-      \message{iexec: this is the content of \iexec at stdout:^^J}%
-      \iexec at typeout{\iexec at stdout}
+    \ifdefined\iexec at null\else%
+    \ifdefined\iexec at log%
+      \message{iexec: This is the content of \iexec at stdout:^^J}%
+      \iexec at typeout{\iexec at stdout}%
       \message{<EOF>^^J}%
     \fi\fi%
 %    \end{macrocode}
+% Then, we check exit code:
+%    \begin{macrocode}
+    \ifdefined\iexec at log\else%
+      \immediate\openin\iexec at retfile=iexec.ret%
+      \read\iexec at retfile to \iexec at ret%
+      \immediate\closein\iexec at retfile%
+      \ifnum\iexec at ret=0\else%
+        \PackageError{iexec}{Exit code is \iexec at ret}{}%
+      \fi%
+    \fi%
+%    \end{macrocode}
 % Then, include the produced output into the current document:
 %    \begin{macrocode}
-    \ifdefined\iexec at null\else
-    \ifdefined\iexec at quiet
-      \message{iexec: Due to 'quiet' option we didn't read
-      the content of '\iexec at stdout' (\pdffilesize{} bytes)^^J}%
+    \ifdefined\iexec at null\else%
+    \ifdefined\iexec at quiet%
+      \ifdefined\iexec at log%
+        \message{iexec: Due to 'quiet' option we didn't read
+        the content of '\iexec at stdout'
+        \ifdefined\pdffilesize(\pdffilesize{\iexec at stdout}
+        bytes)\fi^^J}%
+      \fi%
     \else%
-      \message{iexec: We include the content of
-        '\iexec at stdout' (\pdffilesize{} bytes)...^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: We include the content of
+        '\iexec at stdout'\ifdefined\pdffilesize(\pdffilesize
+        {\iexec at stdout} bytes)\fi...^^J}%
+      \fi%
       \input{\iexec at stdout}%
       \message{iexec: The content of '\iexec at stdout'
       was included into the document^^J}%
@@ -372,17 +384,23 @@
 %    \end{macrocode}
 % Finally, delete the file or leave it untouched:
 %    \begin{macrocode}
-    \ifdefined\iexec at null\else
+    \ifdefined\iexec at null\else%
     \ifiexec at trace%
-      \message{iexec: Due to package option 'trace',
-      the file '\iexec at stdout' was not deleted^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: Due to package option 'trace',
+        the file '\iexec at stdout' was not deleted^^J}%
+      \fi%
     \else%
       \ifdefined\iexec at traceit%
-        \message{iexec: Due to 'trace' option,
-        the file '\iexec at stdout' was not deleted^^J}%
+        \ifdefined\iexec at log%
+          \message{iexec: Due to 'trace' option,
+          the file '\iexec at stdout' was not deleted^^J}%
+        \fi%
       \else%
         \ShellEscape{rm \iexec at stdout}%
-        \message{iexec: The file '\iexec at stdout' was deleted^^J}%
+        \ifdefined\iexec at log%
+          \message{iexec: The file '\iexec at stdout' was deleted^^J}%
+        \fi%
       \fi%
     \fi\fi%
   \endgroup
@@ -393,7 +411,7 @@
 % \Finale
 
 %\clearpage
-%
 %\PrintChanges
+
 %\clearpage
 %\PrintIndex

Modified: trunk/Master/texmf-dist/tex/latex/iexec/iexec.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/iexec/iexec.sty	2022-10-21 19:39:04 UTC (rev 64770)
+++ trunk/Master/texmf-dist/tex/latex/iexec/iexec.sty	2022-10-21 19:39:30 UTC (rev 64771)
@@ -31,7 +31,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{iexec}
-[2022-10-15 0.9.1 Inputable Shell Executions]
+[2022-10-21 0.10.1 Inputable Shell Executions]
 
 
 
@@ -68,6 +68,7 @@
   log/.store in = \iexec at log,
   null/.store in = \iexec at null,
   quiet/.store in = \iexec at quiet,
+  ignore/.store in = \iexec at ignore,
   stdout
 }\makeatother
 
@@ -85,8 +86,10 @@
 }
 \ExplSyntaxOff\makeatother
 
-\makeatletter\newcommand\iexec[2][]{%
-  \begingroup
+\makeatletter
+\newread\iexec at retfile
+\newcommand\iexec[2][]{%
+  \begingroup%
     \pgfqkeys{/iexec}{#1}%
     \ifnum\ShellEscapeStatus=1\else%
       \PackageError{iexec}{You must run TeX processor with
@@ -93,7 +96,9 @@
       --shell-escape option}{}%
     \fi%
     \begingroup%
-      \message{^^J}%
+      \ifdefined\iexec at log%
+        \message{^^J}%
+      \fi%
       \let\%\@percentchar%
       \let\\\@backslashchar%
       \let\{\@charlb%
@@ -101,38 +106,62 @@
       \def\iexec at cmd{(#2)
         \ifdefined\iexec at append>\fi>
         \ifdefined\iexec at null/dev/null\else\iexec at stdout\fi
-        \space\ifdefined\iexec at stderr2>\iexec at stderr\else2>&1\fi}
+        \space\ifdefined\iexec at stderr2>\iexec at stderr\else2>&1\fi
+        \ifdefined\iexec at ignore\else; echo $? >iexec.ret\fi}
       \ShellEscape{\iexec at cmd}%
-      \message{iexec: [\iexec at cmd]^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: [\iexec at cmd]^^J}%
+      \fi%
     \endgroup%
-    \ifdefined\iexec at null\else
-    \ifdefined\iexec at log
-      \message{iexec: this is the content of \iexec at stdout:^^J}%
-      \iexec at typeout{\iexec at stdout}
+    \ifdefined\iexec at null\else%
+    \ifdefined\iexec at log%
+      \message{iexec: This is the content of \iexec at stdout:^^J}%
+      \iexec at typeout{\iexec at stdout}%
       \message{<EOF>^^J}%
     \fi\fi%
-    \ifdefined\iexec at null\else
-    \ifdefined\iexec at quiet
-      \message{iexec: Due to 'quiet' option we didn't read
-      the content of '\iexec at stdout' (\pdffilesize{} bytes)^^J}%
+    \ifdefined\iexec at log\else%
+      \immediate\openin\iexec at retfile=iexec.ret%
+      \read\iexec at retfile to \iexec at ret%
+      \immediate\closein\iexec at retfile%
+      \ifnum\iexec at ret=0\else%
+        \PackageError{iexec}{Exit code is \iexec at ret}{}%
+      \fi%
+    \fi%
+    \ifdefined\iexec at null\else%
+    \ifdefined\iexec at quiet%
+      \ifdefined\iexec at log%
+        \message{iexec: Due to 'quiet' option we didn't read
+        the content of '\iexec at stdout'
+        \ifdefined\pdffilesize(\pdffilesize{\iexec at stdout}
+        bytes)\fi^^J}%
+      \fi%
     \else%
-      \message{iexec: We include the content of
-        '\iexec at stdout' (\pdffilesize{} bytes)...^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: We include the content of
+        '\iexec at stdout'\ifdefined\pdffilesize(\pdffilesize
+        {\iexec at stdout} bytes)\fi...^^J}%
+      \fi%
       \input{\iexec at stdout}%
       \message{iexec: The content of '\iexec at stdout'
       was included into the document^^J}%
     \fi\fi%
-    \ifdefined\iexec at null\else
+    \ifdefined\iexec at null\else%
     \ifiexec at trace%
-      \message{iexec: Due to package option 'trace',
-      the file '\iexec at stdout' was not deleted^^J}%
+      \ifdefined\iexec at log%
+        \message{iexec: Due to package option 'trace',
+        the file '\iexec at stdout' was not deleted^^J}%
+      \fi%
     \else%
       \ifdefined\iexec at traceit%
-        \message{iexec: Due to 'trace' option,
-        the file '\iexec at stdout' was not deleted^^J}%
+        \ifdefined\iexec at log%
+          \message{iexec: Due to 'trace' option,
+          the file '\iexec at stdout' was not deleted^^J}%
+        \fi%
       \else%
         \ShellEscape{rm \iexec at stdout}%
-        \message{iexec: The file '\iexec at stdout' was deleted^^J}%
+        \ifdefined\iexec at log%
+          \message{iexec: The file '\iexec at stdout' was deleted^^J}%
+        \fi%
       \fi%
     \fi\fi%
   \endgroup
@@ -139,6 +168,7 @@
 }\makeatother
 
 
+
 \endinput
 %%
 %% End of file `iexec.sty'.



More information about the tex-live-commits mailing list.