| 1 |
%% |
| 2 |
%% This is file `shellesc.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% shellesc.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% The source is maintained by the LaTeX Project team and bug |
| 12 |
%% reports for it can be opened at https://latex-project.org/bugs/ |
| 13 |
%% (but please observe conditions on bug reports sent to that address!) |
| 14 |
%% |
| 15 |
%% |
| 16 |
%% Copyright (C) 1993-2026 |
| 17 |
%% The LaTeX Project and any individual authors listed elsewhere |
| 18 |
%% in this file. |
| 19 |
%% |
| 20 |
%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'. |
| 21 |
%% -------------------------------------------------------------------------- |
| 22 |
%% |
| 23 |
%% It may be distributed and/or modified under the |
| 24 |
%% conditions of the LaTeX Project Public License, either version 1.3c |
| 25 |
%% of this license or (at your option) any later version. |
| 26 |
%% The latest version of this license is in |
| 27 |
%% https://www.latex-project.org/lppl.txt |
| 28 |
%% and version 1.3c or later is part of all distributions of LaTeX |
| 29 |
%% version 2005/12/01 or later. |
| 30 |
%% |
| 31 |
%% This file may only be distributed together with a copy of the LaTeX |
| 32 |
%% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle' |
| 33 |
%% without such generated files. |
| 34 |
%% |
| 35 |
%% The list of all files belonging to the LaTeX `Tools Bundle' is |
| 36 |
%% given in the file `manifest.txt'. |
| 37 |
%% |
| 38 |
%% Source File: shellesc.dtx |
| 39 |
%% Copyright (C) 2015-2026 |
| 40 |
%% |
| 41 |
%% The LaTeX Project and any individual authors listed elsewhere |
| 42 |
%% in this file. |
| 43 |
%% |
| 44 |
%% This file may be distributed under the terms of the LPPL. |
| 45 |
%% See README for details. |
| 46 |
\ifx\ProvidesPackage\undefined |
| 47 |
\def\next#1#2[#3]{\wlog{#2 #3}} |
| 48 |
\ifx\PackageInfo\undefined\def\PackageInfo#1#2{\wlog{#1: #2}}\fi |
| 49 |
\ifx\PackageWarning\undefined\def\PackageWarning#1#2{\wlog{#1: #2}}\fi |
| 50 |
\expandafter\next\fi |
| 51 |
\ProvidesPackage{shellesc} |
| 52 |
[2023/07/08 v1.0d unified shell escape interface for LaTeX] |
| 53 |
\chardef\shellesc@quotecat\catcode`\" |
| 54 |
\chardef\shellesc@underscorecat\catcode`\_ |
| 55 |
\@makeother\" |
| 56 |
\@makeother\_ |
| 57 |
\chardef\ShellEscapeStatus |
| 58 |
\ifx\pdfshellescape\@undefined |
| 59 |
\ifx\shellescape\@undefined |
| 60 |
\ifx\directlua\@undefined |
| 61 |
\z@ |
| 62 |
\else |
| 63 |
\directlua{% |
| 64 |
tex.sprint((status.shell_escape or os.execute()) .. " ")} |
| 65 |
\fi |
| 66 |
\else |
| 67 |
\shellescape |
| 68 |
\fi |
| 69 |
\else |
| 70 |
\pdfshellescape |
| 71 |
\fi |
| 72 |
\ifcase\ShellEscapeStatus |
| 73 |
\PackageWarning{shellesc}{Shell escape disabled} |
| 74 |
\or |
| 75 |
\PackageInfo {shellesc}{Unrestricted shell escape enabled} |
| 76 |
\else |
| 77 |
\PackageInfo {shellesc}{Restricted shell escape enabled} |
| 78 |
\fi |
| 79 |
\ifx\lastsavedimageresourcepages\@undefined |
| 80 |
\protected\def\ShellEscape{\immediate\write18 } |
| 81 |
\else |
| 82 |
\protected\def\ShellEscape{\directlua\ShellEscape@Lua} |
| 83 |
\fi |
| 84 |
\ifx\lastsavedimageresourcepages\@undefined |
| 85 |
\protected\def\DelayedShellEscape{\relax\write18 } |
| 86 |
\else |
| 87 |
\protected\def\DelayedShellEscape{\latelua\ShellEscape@Lua} |
| 88 |
\fi |
| 89 |
\ifx\directlua\@undefined\else |
| 90 |
\protected\def\ShellEscape@Lua#1{{% |
| 91 |
local status, msg = os.execute("\luaescapestring{#1}")% |
| 92 |
if status == nil then |
| 93 |
texio.write_nl("log",% |
| 94 |
"runsystem(" .. "\luaescapestring{#1}"% |
| 95 |
.. ")...(" .. msg .. ").\string\n") |
| 96 |
elseif status == 0 then |
| 97 |
texio.write_nl("log",% |
| 98 |
"runsystem(" .. "\luaescapestring{#1}"% |
| 99 |
.. ")...executed.\string\n") |
| 100 |
else |
| 101 |
texio.write_nl("log",% |
| 102 |
"runsystem(" .. "\luaescapestring{#1}"% |
| 103 |
.. ")...failed. " .. (msg or "") .. "\string\n") |
| 104 |
end |
| 105 |
}} |
| 106 |
\fi |
| 107 |
\ifx\lastsavedimageresourcepages\@undefined |
| 108 |
\catcode`\"\shellesc@quotecat |
| 109 |
\catcode`\_\shellesc@underscorecat |
| 110 |
\expandafter\endinput |
| 111 |
\fi |
| 112 |
\directlua{% |
| 113 |
shellesc = shellesc or {} |
| 114 |
local function write_or_execute() |
| 115 |
local s = token.scan_int() |
| 116 |
if (s==18) then |
| 117 |
tex.sprint(\the\numexpr\catcodetable@atletter\relax, |
| 118 |
"\string\\ShellEscape ") |
| 119 |
else |
| 120 |
tex.sprint(\the\numexpr\catcodetable@atletter\relax, |
| 121 |
"\string\\shellesc@write " .. s) |
| 122 |
end |
| 123 |
end |
| 124 |
shellesc.write_or_execute=write_or_execute |
| 125 |
} |
| 126 |
\let\shellesc@write\write |
| 127 |
\protected\def\write{\directlua{shellesc.write_or_execute()}} |
| 128 |
\catcode`\"\shellesc@quotecat |
| 129 |
\catcode`\_\shellesc@underscorecat |
| 130 |
\endinput |
| 131 |
%% |
| 132 |
%% End of file `shellesc.sty'. |