[latex3-commits] [git/LaTeX3-latex3-latex3] master: Make \sys_shell_get:nnN(TF) run their argument without expansion (8bef7f1)

Bruno Le Floch bruno at le-floch.fr
Wed Jan 16 23:40:00 CET 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/8bef7f10a343fac4b8be412e4544d25b50646c47

>---------------------------------------------------------------

commit 8bef7f10a343fac4b8be412e4544d25b50646c47
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Wed Jan 16 23:38:06 2019 +0100

    Make \sys_shell_get:nnN(TF) run their argument without expansion


>---------------------------------------------------------------

8bef7f10a343fac4b8be412e4544d25b50646c47
 l3kernel/l3candidates.dtx |   56 ++++++++++++++++++++++++---------------------
 l3kernel/l3file.dtx       |    3 +--
 2 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 23f9563..2114431 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -859,8 +859,11 @@
 %     \cs{sys_shell_get:nnNTF} \Arg{shell~command} \Arg{setup} \meta{tl~var} \Arg{true code} \Arg{false code}
 %   \end{syntax}
 %   Defines \meta{tl} to the text returned by the \meta{shell command}.
-%   Category codes may need to be set appropriately via the \meta{setup}
-%   argument. If shell escape is disabled, the \meta{tl~var} will be empty.
+%   The \meta{shell command} is converted to a string using
+%   \cs{tl_to_str:n}.  Category codes may need to be set appropriately
+%   via the \meta{setup} argument, which is run just before running the
+%   \meta{shell command} (in a group).
+%   If shell escape is disabled, the \meta{tl~var} will be empty.
 %   Note that quote characters (|"|) \emph{cannot} be used inside the
 %   \meta{shell command}.  The \cs{sys_shell_get:nnNTF} conditional
 %   returns \texttt{true} if the shell is available and no quote is
@@ -2921,39 +2924,40 @@
 % \begin{macro}[TF]{\sys_shell_get:nnN}
 % \begin{macro}{\sys_shell_get:nnN,\@@_get:nnN,\@@_get_do:Nw}
 %   Setting using a shell is at this level just a slightly specialised file
-%   operation.
+%   operation, with an additional check for quotes, as these are not supported.
 %    \begin{macrocode}
 \cs_new_protected:Npn \sys_shell_get:nnN #1#2#3
-  { \sys_shell_get:nnNTF {#1} {#2} #3 { } { } }
+  {
+    \sys_shell_get:nnNF {#1} {#2} #3
+      { \tl_clear:N #3 }
+  }
 \prg_new_protected_conditional:Npnn \sys_shell_get:nnN #1#2#3 { T , F , TF }
   {
     \sys_if_shell:TF
-      {
-        \tl_if_in:nnTF {#1} { " }
-          {
-            \__kernel_msg_error:nnx
-              { kernel } { quote-in-shell } {#1}
-            \prg_return_false:
-          }
-          {
-            \@@_get:nnN { | " #1 " } {#2} #3
-            \prg_return_true:
-          }
-      }
+      { \exp_args:No \@@_get:nnN { \tl_to_str:n {#1} } {#2} #3 }
       { \prg_return_false: }
   }
 \cs_new_protected:Npn \@@_get:nnN #1#2#3
   {
-    \if_false: { \fi:
-    \group_begin:
-      \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
-      \exp_args:No \tex_everyeof:D { \c_@@_marker_tl }
-      #2 \scan_stop:
-      \exp_after:wN \@@_get_do:Nw
-      \exp_after:wN #3
-      \exp_after:wN \prg_do_nothing:
-        \tex_input:D #1 \scan_stop:
-    \if_false: } \fi:
+    \tl_if_in:nnTF {#1} { " }
+      {
+        \__kernel_msg_error:nnx
+          { kernel } { quote-in-shell } {#1}
+        \prg_return_false:
+      }
+      {
+        \if_false: { \fi:
+        \group_begin:
+          \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
+          \exp_args:No \tex_everyeof:D { \c_@@_marker_tl }
+          #2 \scan_stop:
+          \exp_after:wN \@@_get_do:Nw
+          \exp_after:wN #3
+          \exp_after:wN \prg_do_nothing:
+            \tex_input:D | "#1" \scan_stop:
+        \if_false: } \fi:
+        \prg_return_true:
+      }
   }
 \exp_args:Nno \use:nn
   { \cs_new_protected:Npn \@@_get_do:Nw #1#2 }
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 63236b4..8eefd9a 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -2189,8 +2189,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \file_get:nnN #1#2#3
   {
-    \file_get:nnNTF {#1} {#2} #3
-      { }
+    \file_get:nnNF {#1} {#2} #3
       { \__kernel_file_missing:n {#1} }
   }
 \prg_new_protected_conditional:Npnn \file_get:nnN #1#2#3 { T , F , TF }





More information about the latex3-commits mailing list