[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add \sys_shell_get_pwd:N (031749e)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Jul 27 10:31:13 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/031749e3094b35e6f83f9d8a95fb66fed1adbfb0

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

commit 031749e3094b35e6f83f9d8a95fb66fed1adbfb0
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Jul 27 09:31:13 2018 +0100

    Add \sys_shell_get_pwd:N


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

031749e3094b35e6f83f9d8a95fb66fed1adbfb0
 l3kernel/l3candidates.dtx               |   45 +++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3expl001.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl001.tlg        |    2 ++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl003.tlg        |    2 ++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 ++
 11 files changed, 65 insertions(+)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index a0b0437..099e6a5 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -1012,6 +1012,16 @@
 %   attempted.
 % \end{function}
 %
+% \begin{function}[added = 2018-07-28]{\sys_shell_get_pwd:N}
+%   \begin{syntax}
+%     \cs{sys_shell_get_pwd:N} \Arg{str var}
+%   \end{syntax}
+%   Sets the \meta{str var} to the present working directory (the output of
+%   |pwd| on Unix or |cd| on Windows). Note that on Windows this will contain
+%   string backslash chars (|\|).  If unrestricted shell escape is not
+%   enabled, no action is taken.
+% \end{function}
+%
 % \section{Additions to \pkg{l3tl}}
 %
 % \begin{function}[EXP,pTF]{\tl_if_single_token:n}
@@ -3206,6 +3216,41 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{variable}{\l_@@_tmp_tl}
+%   Scratch space.
+%    \begin{macrocode}
+\tl_new:N \l_@@_tmp_tl
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\sys_shell_get_pwd:N}
+%   Getting the path is easy: the main work is avoiding loosing any
+%   information. (This information can be obtained using the recorder file:
+%   that does not require shell escape. However, it's hard to see how it might
+%   be useful without the other file functions.)
+%    \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_get_pwd:N #1
+  {
+    \sys_if_shell_unrestricted:T
+      {
+        \exp_not:N \tl_set_from_shell:Nnn \exp_not:N \l_@@_tmp_tl
+          {
+            \char_set_catcode_other:N \exp_not:N \\
+            \char_set_catcode_other:N \exp_not:N \#
+            \char_set_catcode_other:N \exp_not:N \~
+            \char_set_catcode_other:N \exp_not:N \%
+            \char_set_catcode_space:N \exp_not:N \ %
+          }
+          {
+            \sys_if_platform_unix:T { pwd }
+            \sys_if_platform_windows:T { cd }
+          }
+        \str_set:NV #1 \exp_not:N \l_@@_tmp_tl
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Additions to \pkg{l3tl}}
 %
 %    \begin{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 1747e71..e04838d 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5873,6 +5873,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index b97ceef..1416466 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5907,6 +5907,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 45bffff..84160b1 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5907,6 +5907,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 61f18b5..abcb47c 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5904,6 +5904,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 5077d4f..e8eb362 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5877,6 +5877,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 1747e71..e04838d 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5873,6 +5873,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index b97ceef..1416466 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5907,6 +5907,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 45bffff..84160b1 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5907,6 +5907,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 61f18b5..abcb47c 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5904,6 +5904,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 5077d4f..e8eb362 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5877,6 +5877,8 @@ Defining \sys_shell_ren:nnn on line ...
 Defining \__sys_shell_ren:nnn on line ...
 Defining \sys_shell_rm:n on line ...
 Defining \sys_shell_rmdir:n on line ...
+Defining \l__sys_tmp_tl on line ...
+Defining \sys_shell_get_pwd:N on line ...
 Defining \tl_if_single_token_p:n on line ...
 Defining \tl_if_single_token:nT on line ...
 Defining \tl_if_single_token:nF on line ...





More information about the latex3-commits mailing list