[latex3-commits] [latex3/latex3] gh1122-iow-shell-open: Add \iow_shell_open:Nn (closes #1122) (737f630e4)
github at latex-project.org
github at latex-project.org
Thu May 25 11:02:37 CEST 2023
Repository : https://github.com/latex3/latex3
On branch : gh1122-iow-shell-open
Link : https://github.com/latex3/latex3/commit/737f630e4ca6109720a38c5941632198e702c755
>---------------------------------------------------------------
commit 737f630e4ca6109720a38c5941632198e702c755
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu May 25 10:02:37 2023 +0100
Add \iow_shell_open:Nn (closes #1122)
>---------------------------------------------------------------
737f630e4ca6109720a38c5941632198e702c755
l3kernel/CHANGELOG.md | 3 +++
l3kernel/l3file.dtx | 44 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 0eb809ae4..cee227f1f 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Added
+- `\iow_shell_open:Nn` (issue \#1122)
+
## Deprecated
- `\tl_case:Nn(TF)`
- `expl3` package option `enable-debug` (no longer required)
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index c4e5f0b1c..3b21d3e60 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -157,6 +157,23 @@
% \cs{sys_get_shell:nnNTF}.
% \end{function}
%
+% \begin{function}[added = 2023-05-25]{\iow_shell_open:Nn}
+% \begin{syntax}
+% \cs{iow_shell_open:Nn} \meta{stream} \Arg{shell~command}
+% \end{syntax}
+% Opens the \emph{pseudo}-file created by the output of the
+% \meta{shell command} for writing using \meta{stream} as the
+% control sequence for access. If the \meta{stream} was already
+% open it is closed before the new operation begins. The
+% \meta{stream} is available for access immediately and will remain
+% allocated to \meta{shell command} until a \cs{iow_close:N} instruction
+% is given or the \TeX{} run ends.
+% If piped system calls are disabled an error is raised.
+%
+% For details of handling of the \meta{shell command}, see
+% \cs{sys_get_shell:nnNTF}.
+% \end{function}
+%
% \begin{function}[updated = 2012-07-31]
% {\ior_close:N, \ior_close:c, \iow_close:N, \iow_close:c}
% \begin{syntax}
@@ -1169,7 +1186,7 @@
{
\sys_if_shell:TF
{ \exp_args:No \@@_shell_open:nN { \tl_to_str:n {#2} } #1 }
- { \msg_error:nn { ior } { pipe-failed } }
+ { \msg_error:nn { kernel } { pipe-failed } }
}
\cs_new_protected:Npn \@@_shell_open:nN #1#2
{
@@ -1180,7 +1197,7 @@
}
{ \__kernel_ior_open:Nn #2 { |#1 } }
}
-\msg_new:nnnn { ior } { pipe-failed }
+\msg_new:nnnn { kernel } { pipe-failed }
{ Cannot~run~piped~system~commands. }
{
LaTeX~tried~to~call~a~system~process~but~this~was~not~possible.\\
@@ -1634,6 +1651,29 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\iow_shell_open:Nn}
+% \begin{macro}{\@@_shell_open:nN}
+% Very similar to the \texttt{ior} version
+% \begin{macrocode}
+\cs_new_protected:Npn \iow_shell_open:Nn #1#2
+ {
+ \sys_if_shell:TF
+ { \exp_args:No \@@_shell_open:nN { \tl_to_str:n {#2} } #1 }
+ { \msg_error:nn { kernel } { pipe-failed } }
+ }
+\cs_new_protected:Npn \@@_shell_open:nN #1#2
+ {
+ \tl_if_in:nnTF {#1} { " }
+ {
+ \msg_error:nnx
+ { kernel } { quote-in-shell } {#1}
+ }
+ { \__kernel_iow_open:Nn #2 { |#1 } }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\iow_close:N, \iow_close:c}
% Closing a stream is not quite the reverse of opening one. First,
% the close operation is easier than the open one, and second as the
More information about the latex3-commits
mailing list.