-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -965,6 +965,53 @@ | |
% Execute \meta{tokens} through shell escape at shipout. | ||
% \end{function} | ||
% | ||
% \begin{function}[added = 2018-07-27]{\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 \meat{dest}. The file paths 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_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-27]{\sys_shell_ren:nnn} | ||
% \begin{syntax} | ||
% \cs{sys_shell_ren:nnn} \Ag{path} \Arg{old} \Arg{new} | ||
% \end{syntax} | ||
% Renames the files in the meta{\path} from the \meta{old} to \meta{new} | ||
% name (which may include wildcards). The \meta{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_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} | ||
% | ||
% \section{Additions to \pkg{l3tl}} | ||
% | ||
% \begin{function}[EXP,pTF]{\tl_if_single_token:n} | ||
|
@@ -3032,6 +3079,118 @@ | |
% \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~-RLf~ \exp_not:N \tl_to_str:n {#1} ~ \tl_to_str:n {#2} } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
godbyk
|
||
\sys_if_platform_windows:T | ||
{ | ||
xcopy~/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_ren:nnn} | ||
% The differences in syntax between Unix and Windows mean that it's not easy | ||
% to provide |mv|: instead we go with |ren|-like syntax but with arguments | ||
% set up to work with Unix too. | ||
% \begin{macrocode} | ||
\cs_new_protected:Npx \sys_shell_ren:nnn #1#2#3 | ||
{ | ||
\sys_if_shell_unrestricted:T | ||
{ | ||
\sys_shell_now:x | ||
{ | ||
\sys_if_platform_unix:T | ||
{ mv~-f~ \tl_to_str:n { #1 / #2 } ~ \tl_to_str:n { #1 / #3 } } | ||
\sys_if_platform_windows:T | ||
{ | ||
ren~ \exp_not:N \@@_path_to_win:n { #1 / #2 } ~ | ||
\exp_not:N \tl_to_str:n {#3} | ||
} | ||
} | ||
} | ||
} | ||
% \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~-r~ \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} | ||
% | ||
% \subsection{Additions to \pkg{l3tl}} | ||
% | ||
% \begin{macrocode} | ||
|
Quoting this line of code, I've asked this question