[latex3-commits] [git/LaTeX3-latex3-latex3] master: Move l3sys shell functions to new experimental module (c3d729f)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Aug 23 09:24:47 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/c3d729fa3cec4c8d766773889e897751ded325ec
>---------------------------------------------------------------
commit c3d729fa3cec4c8d766773889e897751ded325ec
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Aug 23 08:24:47 2018 +0100
Move l3sys shell functions to new experimental module
>---------------------------------------------------------------
c3d729fa3cec4c8d766773889e897751ded325ec
l3experimental/CHANGELOG.md | 3 +-
l3experimental/README.md | 7 +
l3experimental/l3sys-shell/l3sys-shell.dtx | 367 ++++++++++++++++++++++++++++
l3kernel/CHANGELOG.md | 1 -
l3kernel/l3candidates.dtx | 287 ----------------------
l3kernel/testfiles/m3expl001.luatex.tlg | 11 -
l3kernel/testfiles/m3expl001.ptex.tlg | 11 -
l3kernel/testfiles/m3expl001.tlg | 11 -
l3kernel/testfiles/m3expl001.uptex.tlg | 11 -
l3kernel/testfiles/m3expl001.xetex.tlg | 11 -
l3kernel/testfiles/m3expl003.luatex.tlg | 11 -
l3kernel/testfiles/m3expl003.ptex.tlg | 11 -
l3kernel/testfiles/m3expl003.tlg | 11 -
l3kernel/testfiles/m3expl003.uptex.tlg | 11 -
l3kernel/testfiles/m3expl003.xetex.tlg | 11 -
15 files changed, 376 insertions(+), 399 deletions(-)
diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index c0ba176..385700d 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -1,5 +1,5 @@
# Changelog
-All notable changes to the `l3kernel` bundle since the start of 2018
+All notable changes to the `l3experimental` bundle since the start of 2018
will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
### Added
- `CHANGELOG.md` (fixes #460)
+- `l3sys-shell` for experimental shell functions
## [2018-05-12]
diff --git a/l3experimental/README.md b/l3experimental/README.md
index 75dcf42..f035553 100644
--- a/l3experimental/README.md
+++ b/l3experimental/README.md
@@ -24,6 +24,7 @@ bundles:
* `l3color`
* `l3draw`
* `l3str`
+* `l3sys-shell`
* `xcoffins`
* `xgalley`
@@ -51,6 +52,12 @@ category code 10 ('space'). The `l3str` bundle consists of two parts. The
first is `l3str` itself. This is a collection of functions to act on strings,
including for manipulations such as UTF8 mappings in pdfTeX.
+`l3sys-shell`
+-------------
+
+This module provides abstractions for common shell functions, e.g. file
+deletion and copying.
+
`xcoffins`
----------
diff --git a/l3experimental/l3sys-shell/l3sys-shell.dtx b/l3experimental/l3sys-shell/l3sys-shell.dtx
new file mode 100644
index 0000000..4572b05
--- /dev/null
+++ b/l3experimental/l3sys-shell/l3sys-shell.dtx
@@ -0,0 +1,367 @@
+% \iffalse meta-comment
+%
+%% File: l3sys-shell.dtx Copyright(C) 2018 The LaTeX3 Project
+%
+% It may be distributed and/or modified under the conditions of the
+% LaTeX Project Public License (LPPL), either version 1.3c of this
+% license or (at your option) any later version. The latest version
+% of this license is in the file
+%
+% http://www.latex-project.org/lppl.txt
+%
+% This file is part of the "l3experimental bundle" (The Work in LPPL)
+% and all files in that bundle must be distributed together.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+% https://github.com/latex3/latex3
+%
+% for those people who are interested.
+%
+%<*driver|package>
+\RequirePackage{expl3}
+%</driver|package>
+%<*driver>
+\documentclass[full]{l3doc}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \title{^^A
+% The \pkg{l3sys-shell} package\\ System shell functions^^A
+% }
+%
+% \author{^^A
+% The \LaTeX3 Project\thanks
+% {^^A
+% E-mail:
+% \href{mailto:latex-team at latex-project.org}
+% {latex-team at latex-project.org}^^A
+% }^^A
+% }
+%
+% \date{Released 2018-05-12}
+%
+% \maketitle
+%
+% \begin{documentation}
+%
+% \begin{function}[added = 2018-07-28]{\sys_shell_cp:nn}
+% \begin{syntax}
+% \cs{sys_shell_cp:nn} \Arg{source} \Arg{dest}
+% \end{syntax}
+% Copies the files specified in the \meta{source} (which may include
+% wildcards) to the \meta{dest}. The file paths should be specified using
+% |/| as a path separator. Copying is \emph{not} recursive: only files at
+% the path level given are copied. If unrestricted shell escape is not
+% enabled, no action is attempted.
+% \end{function}
+%
+% \begin{function}[added = 2018-07-27]{\sys_shell_mkdir:n}
+% \begin{syntax}
+% \cs{sys_shell_mkdir:n} \Arg{directory}
+% \end{syntax}
+% Creates the \meta{directory}, which should should be specified using |/| as
+% a path separator. If unrestricted shell escape is not enabled, no action is
+% attempted.
+% \end{function}
+%
+% \begin{function}[added = 2018-07-28]{\sys_shell_mv:nn}
+% \begin{syntax}
+% \cs{sys_shell_mv:nn} \Arg{old} \Arg{new}
+% \end{syntax}
+% Moves the files from the \meta{old} to \meta{new} names/locations: the
+% \meta{old} names may include wildcards. In both arguments, |/| should be
+% used as the path separator. If unrestricted shell escape is not enabled, no
+% action is attempted.
+% \end{function}
+%
+% \begin{function}[added = 2018-07-27]{\sys_shell_rm:n}
+% \begin{syntax}
+% \cs{sys_shell_rm:n} \Arg{files}
+% \end{syntax}
+% Removes the \meta{files} (which may include wildcards). The file path should
+% be specified using |/| as a path separator. If unrestricted shell escape is
+% not enabled, no action is attempted.
+% \end{function}
+%
+% \begin{function}[added = 2018-07-27]{\sys_shell_rmdir:n}
+% \begin{syntax}
+% \cs{sys_shell_rmdir:n} \Arg{directory}
+% \end{syntax}
+% Removes the \meta{directory}, which should should be specified using |/| as
+% a path separator. If unrestricted shell escape is not enabled, no action is
+% attempted.
+% \end{function}
+%
+% \begin{function}[added = 2018-07-28]{\sys_shell_get_pwd:N}
+% \begin{syntax}
+% \cs{sys_shell_get_pwd:N} \meta{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}
+%
+% \begin{function}[added = 2018-07-28]{\sys_shell_split_ls:nN}
+% \begin{syntax}
+% \cs{sys_shell_split_ls:N} \Arg{glob} \meta{seq}
+% \end{syntax}
+% Sets the \meta{seq var} to contain one entry per directory listing
+% (equivalent to |ls -1| or |dir /b|) as specified by the \meta{glob}: the
+% entries are strings. If unrestricted shell is not enabled, no action is
+% taken.
+% \end{function}
+%
+% \end{documentation}
+%
+% \begin{implementation}
+%
+% \section{\pkg{l3sys-shell} implementation}
+%
+% \begin{macrocode}
+%<*initex|package>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<@@=sys>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*package>
+\ProvidesExplPackage{l3sys-shell}{2018-05-12}{}
+ {L3 Experimental system shell functions}
+%</package>
+% \end{macrocode}
+%
+% \begin{macro}[EXP]{\@@_path_to_win:n}
+% \begin{macro}[EXP]{\@@_path_to_win:w}
+% \begin{macro}[EXP]{\@@_path_to_win:N}
+% A simple expandable search-and-replace for providing Windows-style paths.
+% \begin{macrocode}
+\cs_new:Npn \@@_path_to_win:n #1
+ {
+ \exp_after:wN \@@_path_to_win:w \tl_to_str:n {#1} ~ \q_stop
+ }
+\cs_new:Npn \@@_path_to_win:w #1 ~ #2 \q_stop
+ {
+ \@@_path_to_win:N #1 \q_nil
+ \tl_if_empty:nF {#2}
+ {
+ \c_space_tl
+ \@@_path_to_win:w #2 \q_stop
+ }
+ }
+\cs_new:Npn \@@_path_to_win:N #1
+ {
+ \quark_if_nil:NF #1
+ {
+ \token_if_eq_meaning:NNTF #1 /
+ { \c_backslash_str }
+ {#1}
+ \@@_path_to_win:N
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\sys_shell_cp:nn}
+% Simple Unix-like file copying: at some stage we may need a directory-only
+% version as Windows and Unix have different requirements here.
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_cp:nn #1#2
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \sys_shell_now:x
+ {
+ \sys_if_platform_unix:T
+ {
+ cp~-f~ \exp_not:N \tl_to_str:n {#1} ~
+ \exp_not:N \tl_to_str:n {#2}
+ }
+ \sys_if_platform_windows:T
+ {
+ copy~/y~ \exp_not:N \@@_path_to_win:n {#1} ~
+ \exp_not:N \@@_path_to_win:n {#2}
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sys_shell_mkdir:n}
+% Windows (with the extensions) will automatically make directory trees but
+% issues a warning if the directory already exists: avoid by including a
+% test.
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_mkdir:n #1
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \sys_shell_now:x
+ {
+ \sys_if_platform_unix:T
+ { mkdir~-p~ \exp_not:N \tl_to_str:n {#1} }
+ \sys_if_platform_windows:T
+ {
+ if~not~exist~
+ \exp_not:N \@@_path_to_win:n { #1 / nul } ~
+ mkdir~ \exp_not:N \@@_path_to_win:n {#1}
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sys_shell_mv:nn}
+% On Windows we do not have a single |mv| operation, so copy-and-delete
+% instead.
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_mv:nn #1#2
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \sys_shell_now:x
+ {
+ \sys_if_platform_unix:T
+ {
+ mv~ \exp_not:N \tl_to_str:n {#1} ~
+ \exp_not:N \tl_to_str:n {#2}
+ }
+ \sys_if_platform_windows:T
+ {
+ copy~/y~ \exp_not:N \@@_path_to_win:n {#1} ~
+ \exp_not:N \@@_path_to_win:n {#2}
+ \token_to_str:N & \token_to_str:N &
+ del~/f~/q~\exp_not:N \@@_path_to_win:n {#1}
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sys_shell_rm:n}
+% Deletion: obviously a big health warning here!
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_rm:n #1
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \sys_shell_now:x
+ {
+ \sys_if_platform_unix:T
+ { rm~-f~ \exp_not:N \tl_to_str:n {#1} }
+ \sys_if_platform_windows:T
+ { del~/f~/q~ \exp_not:N \@@_path_to_win:n {#1} }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sys_shell_rmdir:n}
+% When removing a directory, we create it first as that avoids errors in
+% the Windows case.
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_rmdir:n #1
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \sys_shell_mkdir:n {#1}
+ \sys_shell_now:x
+ {
+ \sys_if_platform_unix:T
+ { rm~-rf~ \exp_not:N \tl_to_str:n {#1} }
+ \sys_if_platform_windows:T
+ { rmdir~/s~/q~ \exp_not:N \@@_path_to_win:n {#1} }
+ }
+ }
+ }
+% \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}
+%
+% \begin{macro}{\sys_shell_split_ls:nN}
+% Getting a one-per-line listing is easy enough. We need to set
+% \cs{ExplSyntaxOff} as that deals with the end-of-line character. After that,
+% just a case of tidying up. The listing always ends in |^^M| so there is an
+% extra entry to trim.
+% \begin{macrocode}
+\cs_new_protected:Npx \sys_shell_split_ls:nN #1#2
+ {
+ \sys_if_shell_unrestricted:T
+ {
+ \exp_not:N \tl_set_from_shell:Nnn \exp_not:N \l_@@_tmp_tl
+ {
+ \ExplSyntaxOff
+ \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_other:n { 13 }
+ }
+ {
+ \sys_if_platform_unix:T { ls~-1~ #1 }
+ \sys_if_platform_windows:T { dir~/b~ #1 }
+ }
+ \str_set:NV \exp_not:N \l_@@_tmp_tl \exp_not:N \l_@@_tmp_tl
+ \seq_set_split:NnV #2 { \char_generate:nn { `\^^M } { 12 } }
+ \exp_not:N \l_@@_tmp_tl
+ \seq_pop_right:NN #2 \exp_not:N \l_@@_tmp_tl
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</initex|package>
+% \end{macrocode}
+%
+% \end{implementation}
+%
+% \PrintIndex
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 1275e90..1962b30 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -11,7 +11,6 @@ this project uses date-based 'snapshot' version identifiers.
- `\lua_escape:e`, `\lua_now:e` and `\lua_shipout_e:n`
- `\str_case_e:nn(TF)` and `\str_if_eq:ee(TF)`
- `\sys_if_platform_unix:(TF)` and `\sys_if_platform_windows:(TF)`
-- System shell functions, _e.g._ `\sys_shell_mkdir:n`
- `\tl_(g)set_from_shell:Nnn`
## Deprecated
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index ba60ae8..95d2858 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -965,74 +965,6 @@
% Execute \meta{tokens} through shell escape at shipout.
% \end{function}
%
-% \begin{function}[added = 2018-07-28]{\sys_shell_cp:nn}
-% \begin{syntax}
-% \cs{sys_shell_cp:nn} \Arg{source} \Arg{dest}
-% \end{syntax}
-% Copies the files specified in the \meta{source} (which may include
-% wildcards) to the \meta{dest}. The file paths should be specified using
-% |/| as a path separator. Copying is \emph{not} recursive: only files at
-% the path level given are copied. If unrestricted shell escape is not
-% enabled, no action is attempted.
-% \end{function}
-%
-% \begin{function}[added = 2018-07-27]{\sys_shell_mkdir:n}
-% \begin{syntax}
-% \cs{sys_shell_mkdir:n} \Arg{directory}
-% \end{syntax}
-% Creates the \meta{directory}, which should should be specified using |/| as
-% a path separator. If unrestricted shell escape is not enabled, no action is
-% attempted.
-% \end{function}
-%
-% \begin{function}[added = 2018-07-28]{\sys_shell_mv:nn}
-% \begin{syntax}
-% \cs{sys_shell_mv:nn} \Arg{old} \Arg{new}
-% \end{syntax}
-% Moves the files from the \meta{old} to \meta{new} names/locations: the
-% \meta{old} names may include wildcards. In both arguments, |/| should be
-% used as the path separator. If unrestricted shell escape is not enabled, no
-% action is attempted.
-% \end{function}
-%
-% \begin{function}[added = 2018-07-27]{\sys_shell_rm:n}
-% \begin{syntax}
-% \cs{sys_shell_rm:n} \Arg{files}
-% \end{syntax}
-% Removes the \meta{files} (which may include wildcards). The file path should
-% be specified using |/| as a path separator. If unrestricted shell escape is
-% not enabled, no action is attempted.
-% \end{function}
-%
-% \begin{function}[added = 2018-07-27]{\sys_shell_rmdir:n}
-% \begin{syntax}
-% \cs{sys_shell_rmdir:n} \Arg{directory}
-% \end{syntax}
-% Removes the \meta{directory}, which should should be specified using |/| as
-% a path separator. If unrestricted shell escape is not enabled, no action is
-% attempted.
-% \end{function}
-%
-% \begin{function}[added = 2018-07-28]{\sys_shell_get_pwd:N}
-% \begin{syntax}
-% \cs{sys_shell_get_pwd:N} \meta{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}
-%
-% \begin{function}[added = 2018-07-28]{\sys_shell_split_ls:nN}
-% \begin{syntax}
-% \cs{sys_shell_split_ls:N} \Arg{glob} \meta{seq}
-% \end{syntax}
-% Sets the \meta{seq var} to contain one entry per directory listing
-% (equivalent to |ls -1| or |dir /b|) as specified by the \meta{glob}: the
-% entries are strings. If unrestricted shell is not enabled, no action is
-% taken.
-% \end{function}
-%
% \section{Additions to \pkg{l3tl}}
%
% \begin{function}[EXP,pTF]{\tl_if_single_token:n}
@@ -3067,225 +2999,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_path_to_win:n}
-% \begin{macro}[EXP]{\@@_path_to_win:w}
-% \begin{macro}[EXP]{\@@_path_to_win:N}
-% A simple expandable search-and-replace for providing Windows-style paths.
-% \begin{macrocode}
-\cs_new:Npn \@@_path_to_win:n #1
- {
- \exp_after:wN \@@_path_to_win:w \tl_to_str:n {#1} ~ \q_stop
- }
-\cs_new:Npn \@@_path_to_win:w #1 ~ #2 \q_stop
- {
- \@@_path_to_win:N #1 \q_nil
- \tl_if_empty:nF {#2}
- {
- \c_space_tl
- \@@_path_to_win:w #2 \q_stop
- }
- }
-\cs_new:Npn \@@_path_to_win:N #1
- {
- \quark_if_nil:NF #1
- {
- \token_if_eq_meaning:NNTF #1 /
- { \c_backslash_str }
- {#1}
- \@@_path_to_win:N
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\sys_shell_cp:nn}
-% Simple Unix-like file copying: at some stage we may need a directory-only
-% version as Windows and Unix have different requirements here.
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_cp:nn #1#2
- {
- \sys_if_shell_unrestricted:T
- {
- \sys_shell_now:x
- {
- \sys_if_platform_unix:T
- {
- cp~-f~ \exp_not:N \tl_to_str:n {#1} ~
- \exp_not:N \tl_to_str:n {#2}
- }
- \sys_if_platform_windows:T
- {
- copy~/y~ \exp_not:N \@@_path_to_win:n {#1} ~
- \exp_not:N \@@_path_to_win:n {#2}
- }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sys_shell_mkdir:n}
-% Windows (with the extensions) will automatically make directory trees but
-% issues a warning if the directory already exists: avoid by including a
-% test.
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_mkdir:n #1
- {
- \sys_if_shell_unrestricted:T
- {
- \sys_shell_now:x
- {
- \sys_if_platform_unix:T
- { mkdir~-p~ \exp_not:N \tl_to_str:n {#1} }
- \sys_if_platform_windows:T
- {
- if~not~exist~
- \exp_not:N \@@_path_to_win:n { #1 / nul } ~
- mkdir~ \exp_not:N \@@_path_to_win:n {#1}
- }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sys_shell_mv:nn}
-% On Windows we do not have a single |mv| operation, so copy-and-delete
-% instead.
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_mv:nn #1#2
- {
- \sys_if_shell_unrestricted:T
- {
- \sys_shell_now:x
- {
- \sys_if_platform_unix:T
- {
- mv~ \exp_not:N \tl_to_str:n {#1} ~
- \exp_not:N \tl_to_str:n {#2}
- }
- \sys_if_platform_windows:T
- {
- copy~/y~ \exp_not:N \@@_path_to_win:n {#1} ~
- \exp_not:N \@@_path_to_win:n {#2}
- \token_to_str:N & \token_to_str:N &
- del~/f~/q~\exp_not:N \@@_path_to_win:n {#1}
- }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sys_shell_rm:n}
-% Deletion: obviously a big health warning here!
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_rm:n #1
- {
- \sys_if_shell_unrestricted:T
- {
- \sys_shell_now:x
- {
- \sys_if_platform_unix:T
- { rm~-f~ \exp_not:N \tl_to_str:n {#1} }
- \sys_if_platform_windows:T
- { del~/f~/q~ \exp_not:N \@@_path_to_win:n {#1} }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\sys_shell_rmdir:n}
-% When removing a directory, we create it first as that avoids errors in
-% the Windows case.
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_rmdir:n #1
- {
- \sys_if_shell_unrestricted:T
- {
- \sys_shell_mkdir:n {#1}
- \sys_shell_now:x
- {
- \sys_if_platform_unix:T
- { rm~-rf~ \exp_not:N \tl_to_str:n {#1} }
- \sys_if_platform_windows:T
- { rmdir~/s~/q~ \exp_not:N \@@_path_to_win:n {#1} }
- }
- }
- }
-% \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}
-%
-% \begin{macro}{\sys_shell_split_ls:nN}
-% Getting a one-per-line listing is easy enough. We need to set
-% \cs{ExplSyntaxOff} as that deals with the end-of-line character. After that,
-% just a case of tidying up. The listing always ends in |^^M| so there is an
-% extra entry to trim.
-% \begin{macrocode}
-\cs_new_protected:Npx \sys_shell_split_ls:nN #1#2
- {
- \sys_if_shell_unrestricted:T
- {
- \exp_not:N \tl_set_from_shell:Nnn \exp_not:N \l_@@_tmp_tl
- {
- \ExplSyntaxOff
- \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_other:n { 13 }
- }
- {
- \sys_if_platform_unix:T { ls~-1~ #1 }
- \sys_if_platform_windows:T { dir~/b~ #1 }
- }
- \str_set:NV \exp_not:N \l_@@_tmp_tl \exp_not:N \l_@@_tmp_tl
- \seq_set_split:NnV #2 { \char_generate:nn { `\^^M } { 12 } }
- \exp_not:N \l_@@_tmp_tl
- \seq_pop_right:NN #2 \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 d5cae7a..1439c14 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5864,17 +5864,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 82108c8..6058a58 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5898,17 +5898,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 2d3ae54..90fb415 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5898,17 +5898,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 5d5e139..7ea0bb0 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5895,17 +5895,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 6772d70..9d69c10 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5868,17 +5868,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 d5cae7a..1439c14 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5864,17 +5864,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 82108c8..6058a58 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5898,17 +5898,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 2d3ae54..90fb415 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5898,17 +5898,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 5d5e139..7ea0bb0 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5895,17 +5895,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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 6772d70..9d69c10 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5868,17 +5868,6 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
-Defining \__sys_path_to_win:n on line ...
-Defining \__sys_path_to_win:w on line ...
-Defining \__sys_path_to_win:N on line ...
-Defining \sys_shell_cp:nn on line ...
-Defining \sys_shell_mkdir:n on line ...
-Defining \sys_shell_mv:nn 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 \sys_shell_split_ls:nN 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