[latex3-commits] [git/LaTeX3-latex3-latex3] master: Implement \sys_shell_get:nnNTF and simplify end-of-file business (1945c08)
Bruno Le Floch
bruno at le-floch.fr
Wed Jan 16 23:03:59 CET 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/1945c08f47671fd36022c537e630d576f749aed4
>---------------------------------------------------------------
commit 1945c08f47671fd36022c537e630d576f749aed4
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Wed Jan 16 23:00:26 2019 +0100
Implement \sys_shell_get:nnNTF and simplify end-of-file business
>---------------------------------------------------------------
1945c08f47671fd36022c537e630d576f749aed4
l3kernel/CHANGELOG.md | 2 +-
l3kernel/l3candidates.dtx | 48 +++++++++++++++++++------------
l3kernel/testfiles/m3expl001.luatex.tlg | 7 +++--
l3kernel/testfiles/m3expl001.ptex.tlg | 7 +++--
l3kernel/testfiles/m3expl001.tlg | 7 +++--
l3kernel/testfiles/m3expl001.uptex.tlg | 7 +++--
l3kernel/testfiles/m3expl001.xetex.tlg | 7 +++--
l3kernel/testfiles/m3expl003.luatex.tlg | 7 +++--
l3kernel/testfiles/m3expl003.ptex.tlg | 7 +++--
l3kernel/testfiles/m3expl003.tlg | 7 +++--
l3kernel/testfiles/m3expl003.uptex.tlg | 7 +++--
l3kernel/testfiles/m3expl003.xetex.tlg | 7 +++--
12 files changed, 81 insertions(+), 39 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index c80334c..1d81f7a 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -10,7 +10,7 @@ this project uses date-based 'snapshot' version identifiers.
### Added
- `\file_get:nnN` and `\file_get:nnNTF`
-- Experimental function `\sys_shell_get:nnN`
+- Experimental functions `\sys_shell_get:nnN` and `\sys_shell_get:nnNTF`
### Changed
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index e9ac714..23f9563 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -853,14 +853,19 @@
% \section{Additions to \pkg{l3sys}}
%
% \begin{function}[added = 2019-01-16]{\sys_shell_get:nnN}
+% \begin{function}[TF,added = 2019-01-16]{\sys_shell_get:nnN}
% \begin{syntax}
% \cs{sys_shell_get:nnN} \Arg{shell~command} \Arg{setup} \meta{tl~var}
+% \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.
% Note that quote characters (|"|) \emph{cannot} be used inside the
-% \meta{shell command}.
+% \meta{shell command}. The \cs{sys_shell_get:nnNTF} conditional
+% returns \texttt{true} if the shell is available and no quote is
+% detected, and \texttt{false} otherwise.
+% \end{function}
% \end{function}
%
% \begin{variable}[added = 2018-05-02]{\c_sys_engine_version_str}
@@ -2913,49 +2918,56 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}{\sys_shell_get:nnN}
-% \begin{macro}{\@@_get:nNn}
-% \begin{macro}{\@@_get_do:w}
+% \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.
% \begin{macrocode}
\cs_new_protected:Npn \sys_shell_get:nnN #1#2#3
+ { \sys_shell_get:nnNTF {#1} {#2} #3 { } { } }
+\prg_new_protected_conditional:Npnn \sys_shell_get:nnN #1#2#3 { T , F , TF }
{
\sys_if_shell:TF
{
- \tl_set:Nn \l_@@_internal_tl {#1}
- \tl_if_in:NnTF \l_@@_internal_tl { " }
+ \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:
}
- { \@@_get:nNn { | " #1 " } #3 {#2} }
}
- { #1 #2 { } }
+ { \prg_return_false: }
}
-\cs_new_protected:Npn \@@_get:nNn #1#2#3
+\cs_new_protected:Npn \@@_get:nnN #1#2#3
{
+ \if_false: { \fi:
\group_begin:
- \exp_args:No \tex_everyeof:D
- { \c_@@_marker_tl \exp_not:N }
- #3 \scan_stop:
- \exp_after:wN \@@_get_do:w
+ \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:
- \exp_args:NNNo \group_end:
- \tl_set:Nn #2 \l_@@_internal_tl
+ \if_false: } \fi:
}
\exp_args:Nno \use:nn
- { \cs_new_protected:Npn \@@_get_do:w #1 }
+ { \cs_new_protected:Npn \@@_get_do:Nw #1#2 }
{ \c_@@_marker_tl }
- { \tl_set:No \l_@@_internal_tl {#1} }
+ {
+ \group_end:
+ \tl_set:No #1 {#2}
+ }
\__kernel_msg_new:nnnn { kernel } { quote-in-shell }
{ Quotes~in~shell~command~'#1'. }
{ Shell~commands~cannot~contain~quotes~("). }
% \end{macrocode}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{variable}{\c_sys_platform_str}
% Detecting the platform on \LuaTeX{} is easy: for other engines, we use
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 3f6c244..9d34754 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5894,8 +5894,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index abd1b1c..c0260e5 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5927,8 +5927,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 2acf3cb..d0375f4 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5927,8 +5927,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index d9c250d..4a5ba6f 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5924,8 +5924,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 25b0000..eceb662 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5897,8 +5897,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 3f6c244..9d34754 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5894,8 +5894,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index abd1b1c..c0260e5 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5927,8 +5927,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 2acf3cb..d0375f4 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5927,8 +5927,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index d9c250d..4a5ba6f 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5924,8 +5924,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 25b0000..eceb662 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5897,8 +5897,11 @@ Defining \c_sys_shell_escape_int on line ...
Defining \l__sys_internal_tl on line ...
Defining \c__sys_marker_tl on line ...
Defining \sys_shell_get:nnN on line ...
-Defining \__sys_get:nNn on line ...
-Defining \__sys_get_do:w on line ...
+Defining \sys_shell_get:nnNT on line ...
+Defining \sys_shell_get:nnNF on line ...
+Defining \sys_shell_get:nnNTF on line ...
+Defining \__sys_get:nnN on line ...
+Defining \__sys_get_do:Nw on line ...
Defining message LaTeX/kernel/quote-in-shell on line ...
Defining \c_sys_platform_str on line ...
Defining \sys_if_platform_unix:T on line ...
More information about the latex3-commits
mailing list