Skip to content

Commit

Permalink
Make \sys_shell_get:nnN(TF) run their argument without expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Le Floch committed Jan 16, 2019
1 parent 1945c08 commit 8bef7f1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
56 changes: 30 additions & 26 deletions l3kernel/l3candidates.dtx
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
3 changes: 1 addition & 2 deletions l3kernel/l3file.dtx
Expand Up @@ -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 }
Expand Down

0 comments on commit 8bef7f1

Please sign in to comment.