[latex3-commits] [git/LaTeX3-latex3-latex3] master: Print result of shell escape to .log with LuaTeX (c999e6972)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Oct 17 14:31:12 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/c999e6972b22b1d601801a6ecda0d272511f09ee
>---------------------------------------------------------------
commit c999e6972b22b1d601801a6ecda0d272511f09ee
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Oct 17 13:31:12 2019 +0100
Print result of shell escape to .log with LuaTeX
>---------------------------------------------------------------
c999e6972b22b1d601801a6ecda0d272511f09ee
l3kernel/CHANGELOG.md | 4 ++++
l3kernel/l3luatex.dtx | 27 +++++++++++++++++++++++++++
l3kernel/l3sys.dtx | 4 ++--
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 85fbfb503..c76118a83 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,10 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Added
+
+- Lua function `l3kernel.shellescape()`
+
## [2019-10-14]
### Fixed
diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index 03b554401..73f5eee0b 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -183,6 +183,13 @@
% Resets the timer used by |l3kernel.elapsetime|.
% \end{function}
%
+% \begin{function}{l3kernel.shellescape}
+% \begin{syntax}
+% |l3kernel.shellescape(|\meta{cmd}|)|
+% \end{syntax}
+% Executes the \meta{cmd} and prints to the log as for \pdfTeX{}.
+% \end{function}
+%
% \begin{function}{l3kernel.strcmp}
% \begin{syntax}
% |l3kernel.strcmp(|\meta{str one}, \meta{str two}|)|
@@ -311,6 +318,7 @@ local md5 = md5
local os = os
local string = string
local tex = tex
+local texio = texio
local unicode = unicode
% \end{macrocode}
%
@@ -326,10 +334,12 @@ local md5_sum = md5.sum
local open = io.open
local os_clock = os.clock
local os_date = os.date
+local os_exec = os.excute
local setcatcode = tex.setcatcode
local sprint = tex.sprint
local cprint = tex.cprint
local write = tex.write
+local write_nl = texio.write_nl
% \end{macrocode}
%
% Newer Con\TeX{}t releases replace the |unicode| library by |utf|.
@@ -492,6 +502,23 @@ l3kernel.strcmp = strcmp
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{l3kernel.shellescape}
+% Replicating the \pdfTeX{} log interaction for shell escape.
+% \begin{macrocode}
+local function shellescape(cmd)
+ local status,msg = os_exec(cmd)
+ if status == nil then
+ write_nl("log","runsystem(" .. cmd .. ")...(" .. msg .. ")\n" )
+ elseif status = 0 then
+ write_nl("log","runsystem(" .. cmd .. ")...executed\n" )
+ else
+ write_nl("log","runsystem(" .. cmd .. ")...failed .. " (msg or "") .. "\n" )
+ end
+end
+l3kernel.shellescape = shellescape
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Generic \Lua{} and font support}
%
% \begin{macrocode}
diff --git a/l3kernel/l3sys.dtx b/l3kernel/l3sys.dtx
index 06ef4cd73..398dd2c10 100644
--- a/l3kernel/l3sys.dtx
+++ b/l3kernel/l3sys.dtx
@@ -556,7 +556,7 @@
\cs_new_protected:Npn \sys_shell_now:n #1
{
\lua_now:e
- { os.execute(" \lua_escape:e { \tl_to_str:n {#1} } ") }
+ { l3kernel.shellescape(" \lua_escape:e { \tl_to_str:n {#1} } ") }
}
}
{
@@ -575,7 +575,7 @@
\cs_new_protected:Npn \sys_shell_shipout:n #1
{
\lua_shipout_e:n
- { os.execute(" \lua_escape:e { \tl_to_str:n {#1} } ") }
+ { l3kernel.shellescape(" \lua_escape:e { \tl_to_str:n {#1} } ") }
}
}
{
More information about the latex3-commits
mailing list