texlive[64077] Master/texmf-dist: lt3luabridge (8aug22)

commits+karl at tug.org commits+karl at tug.org
Mon Aug 8 22:59:11 CEST 2022


Revision: 64077
          http://tug.org/svn/texlive?view=revision&revision=64077
Author:   karl
Date:     2022-08-08 22:59:11 +0200 (Mon, 08 Aug 2022)
Log Message:
-----------
lt3luabridge (8aug22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.context
    trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.latex
    trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.plaintex
    trunk/Master/texmf-dist/doc/generic/lt3luabridge/lt3luabridge.pdf
    trunk/Master/texmf-dist/source/generic/lt3luabridge/lt3luabridge.dtx
    trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.sty
    trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.tex

Modified: trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.context
===================================================================
--- trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.context	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.context	2022-08-08 20:59:11 UTC (rev 64077)
@@ -1,4 +1,5 @@
 \usemodule[t][lt3luabridge]
+\luabridgeExecute{x = 1 -- this will have no effect due to sandboxing}
 \starttext
-$ 1 + 2 = \luabridgeExecute{ print(1 + 2) } $
+$ 1 + 2 = \luabridgeExecute{if true then print(1 + 2) end} $
 \stoptext

Modified: trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.latex
===================================================================
--- trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.latex	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.latex	2022-08-08 20:59:11 UTC (rev 64077)
@@ -1,5 +1,6 @@
 \documentclass{standalone}
 \usepackage{lt3luabridge}
+\luabridgeExecute{x = 1 -- this will have no effect due to sandboxing}
 \begin{document}
-$ 1 + 2 = \luabridgeExecute{ print(1 + 2) } $
+$ 1 + 2 = \luabridgeExecute{if true then print(1 + 2) end} $
 \end{document}

Modified: trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.plaintex
===================================================================
--- trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.plaintex	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/doc/generic/lt3luabridge/example.plaintex	2022-08-08 20:59:11 UTC (rev 64077)
@@ -1,3 +1,4 @@
 \input lt3luabridge\relax
-$ 1 + 2 = \luabridgeExecute{ print(1 + 2) } $
+\luabridgeExecute{x = 1 -- this will have no effect due to sandboxing}
+$ 1 + 2 = \luabridgeExecute{if x == nil then print(1 + 2) end} $
 \bye

Modified: trunk/Master/texmf-dist/doc/generic/lt3luabridge/lt3luabridge.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/generic/lt3luabridge/lt3luabridge.dtx
===================================================================
--- trunk/Master/texmf-dist/source/generic/lt3luabridge/lt3luabridge.dtx	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/source/generic/lt3luabridge/lt3luabridge.dtx	2022-08-08 20:59:11 UTC (rev 64077)
@@ -47,7 +47,7 @@
 %    }^^A
 % }
 %
-% \date{Released 2022-06-26}
+% \date{Released 2022-08-08}
 %
 % \maketitle
 %
@@ -80,7 +80,7 @@
 % The interface for executing \Lua{} code mimics the \cs{lua_now:n} function
 % from \pkg{l3luatex}.
 %
-% \begin{function}[added = 2022-06-26]{\luabridge_now:n, \luabridge_now:e}
+% \begin{function}[added = 2022-06-26, updated=2022-07-31]{\luabridge_now:n, \luabridge_now:e}
 %   \begin{syntax}
 %     \cs{luabridge_now:n} \Arg{token list}
 %   \end{syntax}
@@ -94,14 +94,13 @@
 %
 %   Unlike \cs{lua_now:n}, \cs{luabridge_now:n} may execute \meta{\Lua{} input}
 %   in a separate process from \TeX. Therefore, you should not interact with
-%   \TeX{} from \meta{\Lua{} input}. The only exception is the standard output
-%   produced by \meta{\Lua{} input} using for example the |print()| \Lua{}
-%   function like in the example at the top of this page. The standard output
-%   will be inserted into \TeX's input stream after \meta{\Lua{} input} has
-%   been processed at the latest.
+%   \TeX{} from \meta{\Lua{} input} or create global variables. The only
+%   exception is the standard output produced by the |print()| \Lua{} function
+%   like in the example at the top of this page. The standard output of
+%   |print()| will be inserted into \TeX's input stream.
 % \end{function}
 %
-% \begin{function}[added = 2022-06-26]{\luabridgeExecute}
+% \begin{function}[added = 2022-06-26, updated=2022-07-31]{\luabridgeExecute}
 %   \begin{syntax}
 %     \cs{luabridgeExecute} \Arg{token list}
 %   \end{syntax}
@@ -123,14 +122,10 @@
 %   package to one of the constants described below.
 % \end{variable}
 %
-% \begin{variable}[added = 2022-06-26]{\c_luabridge_method_write_eighteen_int}
+% \begin{variable}[added = 2022-07-31]{\c_luabridge_method_shell_int}
 %   Use shell escape through the \cs{write18} \TeX{} command to execute \Lua{} code.
 % \end{variable}
 %
-% \begin{variable}[added = 2022-06-26]{\c_luabridge_method_os_execute_int}
-%   Use shell escape through the |os.execute()| Lua function to execute \Lua{} code.
-% \end{variable}
-%
 % \begin{variable}[added = 2022-06-26]{\c_luabridge_method_directlua_int}
 %   Use the \cs{directlua} primitive of Lua\TeX{} to execute \Lua{} code.
 % \end{variable}
@@ -162,16 +157,6 @@
 %   \cs{g_luabridge_helper_script_filename_str}.
 % \end{variable}
 %
-% \begin{variable}[added = 2022-06-26]{\g_luabridge_standard_output_filename_str}
-%   This variable controls the filename of a helper file that will contain the
-%   standard output produced by the |texlua| interpreter (if any).
-% \end{variable}
-%
-% \begin{variable}[added = 2022-06-26]{\c_luabridge_default_standard_output_filename_str}
-%   This constant is the default value of
-%   \cs{g_luabridge_standard_output_filename_str}.
-% \end{variable}
-%
 % \begin{variable}[added = 2022-06-26]{\g_luabridge_error_output_filename_str}
 %   This variable controls the filename of a helper file that will contain the
 %   error output produced by the |texlua| interpreter (if any).
@@ -198,70 +183,55 @@
 \fi
 \ExplSyntaxOn
 \int_const:Nn
-  \c_luabridge_method_write_eighteen_int
+  \c_luabridge_method_directlua_int
   { 0 }
 \int_const:Nn
-  \c_luabridge_method_os_execute_int
+  \c_luabridge_method_shell_int
   { 1 }
-\int_const:Nn
-  \c_luabridge_method_directlua_int
-  { 2 }
 \int_if_exist:NF
   \g_luabridge_method_int
   {
     \int_new:N
       \g_luabridge_method_int
-    \sys_if_engine_luatex:TF
-      {
-        \int_gset_eq:NN
-          \g_luabridge_method_int
-          \c_luabridge_method_directlua_int
-      }
-      {
-        \int_gset_eq:NN
-          \g_luabridge_method_int
-          \c_luabridge_method_write_eighteen_int
-      }
+      \sys_if_engine_luatex:TF
+        {
+          \int_gset_eq:NN
+            \g_luabridge_method_int
+            \c_luabridge_method_directlua_int
+        }
+        {
+          \int_gset_eq:NN
+            \g_luabridge_method_int
+            \c_luabridge_method_shell_int
+        }
   }
 \msg_new:nnn
   { luabridge }
-  { unknown-method }
+  { method-shell }
   {
-    Unknown~bridging~method:~#1
+    Using~shell~escape~as~the~bridging~method
   }
 \msg_new:nnn
   { luabridge }
-  { method-write-eighteen }
+  { method-directlua }
   {
-    Using~shell~escape~via~write18~as~the~bridging~method
+    Using~direct~Lua~access~as~the~bridging~method
   }
 \msg_new:nnn
   { luabridge }
-  { method-os-execute }
+  { unknown-method }
   {
-    Using~shell~escape~via~os.execute()~as~the~bridging~method
+    Unknown~bridging~method:~#1
   }
-\msg_new:nnn
-  { luabridge }
-  { method-directlua }
-  {
-    Using~direct~Lua~access~as~the~bridging~method
-  }
 \int_case:nnF
   { \g_luabridge_method_int }
   {
-    { \c_luabridge_method_write_eighteen_int }
+    { \c_luabridge_method_shell_int }
       {
         \msg_info:nn
           { luabridge }
-          { method-write-eighteen }
+          { method-shell }
       }
-    { \c_luabridge_method_os_execute_int }
-      {
-        \msg_info:nn
-          { luabridge }
-          { method-os-execute }
-      }
     { \c_luabridge_method_directlua_int }
       {
         \msg_info:nn
@@ -278,101 +248,11 @@
       { unknown-method }
       \g_luabridge_method_int
   }
-\bool_if:nTF
+\int_compare:nNnT
+  { \g_luabridge_method_int }
+  =
+  { \c_luabridge_method_shell_int }
   {
-    \int_compare_p:nNn
-      { \g_luabridge_method_int }
-      =
-      { \c_luabridge_method_write_eighteen_int } ||
-    \int_compare_p:nNn
-      { \g_luabridge_method_int }
-      =
-      { \c_luabridge_method_os_execute_int }
-  }
-  {
-    \int_const:Nn
-      \c_@@_level_disabled_int
-      { 0 }
-    \int_const:Nn
-      \c_@@_level_enabled_int
-      { 1 }
-    \int_const:Nn
-      \c_@@_level_restricted_int
-      { 2 }
-    \int_new:N
-      \l_@@_level_int
-    \cs_if_exist:NTF
-      \pdfshellescape
-      {
-        \int_gset:Nn
-          \l_@@_level_int
-          { \pdfshellescape }
-      }
-      {
-        \cs_if_exist:NTF
-          \shellescape
-          {
-            \int_gset:Nn
-              \l_@@_level_int
-              { \shellescape }
-          }
-          {
-            \int_case:nnF
-              { \g_luabridge_method_int }
-              {
-                { \c_luabridge_method_write_eighteen_int }
-                  {
-                    \int_gset_eq:NN
-                      \l_@@_level_int
-                      \c_@@_level_enabled_int
-                  }
-              }
-              {
-                \int_gset:Nn
-                  \l_@@_level_int
-                  {
-                    \lua_now:n
-                      {
-                        tex.sprint(status.shell_escape or "1")
-                      }
-                  }
-              }
-          }
-      }
-    \msg_new:nnn
-      { luabridge }
-      { unknown-level }
-      {
-        Unknown~shell~escape~level:~#1
-      }
-    \msg_new:nnnn
-      { luabridge }
-      { level-disabled }
-      {
-        Shell~escape~seems~to~be~disabled
-      }
-      {
-        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
-        --enable-write18~flag,~or~write~shell_escape=t~in~the~
-        texmf.cnf~file.
-      }
-    \msg_new:nnn
-      { luabridge }
-      { level-enabled }
-      {
-        Shell~escape~seems~to~be~enabled
-      }
-    \msg_new:nnnn
-      { luabridge }
-      { level-restricted }
-      {
-        Shell~escape~seems~to~be~restricted
-      }
-      {
-        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
-        --enable-write18~flag,~or~write~shell_escape=t~in~the~
-        texmf.cnf~file.
-      }
     \str_const:Nn
       \c_luabridge_default_output_dirname_str
       { . }
@@ -382,80 +262,6 @@
     \str_const:Nx
       \c_luabridge_default_error_output_filename_str
       { \jobname.luabridge.err }
-    \str_const:Nx
-      \c_luabridge_default_standard_output_filename_str
-      { \jobname.luabridge.out }
-    \int_case:nnF
-      { \l_@@_level_int }
-      {
-        { \c_@@_level_disabled_int }
-          {
-            \msg_warning:nn
-              { luabridge }
-              { level-disabled }
-          }
-        { \c_@@_level_enabled_int }
-          {
-            \msg_info:nn
-              { luabridge }
-              { level-enabled }
-          }
-        { \c_@@_level_restricted_int }
-          {
-            \msg_warning:nn
-              { luabridge }
-              { level-restricted }
-          }
-      }
-      {
-        \msg_error:nnx
-          { luabridge }
-          { unknown-level }
-          { \l_@@_level_int }
-      }
-    \cs_new:Nn
-      \_luabridge_assert_shell_escape:
-      {
-        \int_case:nnF
-          { \l_@@_level_int }
-          {
-            { \c_@@_level_disabled_int }
-              {
-                \msg_error:nn
-                  { luabridge }
-                  { level-disabled }
-              }
-          }
-      }
-    \int_case:nn
-      { \g_luabridge_method_int }
-      {
-        { \c_luabridge_method_write_eighteen_int }
-          {
-            \cs_new:Nn
-              \_luabridge_execute_shell:n
-              {
-                \_luabridge_assert_shell_escape:
-                \immediate
-                  \write 18
-                    { #1 }
-              }
-          }
-        { \c_luabridge_method_os_execute_int }
-          {
-            \cs_new:Nn
-              \_luabridge_execute_shell:n
-              {
-                \_luabridge_assert_shell_escape:
-                \lua_now:e
-                  {
-                    os.execute(
-                      " \lua_escape:e { #1 } "
-                    )
-                  }
-              }
-          }
-      }
     \str_if_exist:NF
       \g_luabridge_output_dirname_str
       {
@@ -479,20 +285,11 @@
           \g_luabridge_error_output_filename_str
           \c_luabridge_default_error_output_filename_str
       }
-    \str_if_exist:NF
-      \g_luabridge_standard_output_filename_str
-      {
-        \str_gset_eq:NN
-          \g_luabridge_standard_output_filename_str
-          \c_luabridge_default_standard_output_filename_str
-      }
-    \cs:w newwrite \cs_end:
-      \l_@@_output_stream
     \cs_new:Nn
       \luabridge_now:n
       {
-        \immediate \openout
-          \l_@@_output_stream
+        \iow_open:NV
+          \g_tmpa_iow
           \g_luabridge_helper_script_filename_str
         \msg_info:nnV
           { luabridge }
@@ -504,19 +301,20 @@
         \tl_set:Nx
           \l_tmpb_tl
           {
-            local~ran_ok,~error~=~pcall(function()~
-              local~ran_ok,~kpse~=~pcall(require,~"kpse")~
-              if~ran_ok~then~kpse.set_program_name("luatex")~end~
-              \exp_not:V \l_tmpa_tl~
-            end)~
+            local~ran_ok, error = pcall(function()
+              local~ran_ok, kpse = pcall(require,~"kpse")
+              if~ran_ok~then~kpse.set_program_name("luatex") end~
+              \exp_not:V \l_tmpa_tl
+              \iow_newline:
+            end)
             if~not~ran_ok~then~
-              local~file~=~io.open("
+              local~file = io.open("
                 \g_luabridge_output_dirname_str /
                 \g_luabridge_error_output_filename_str
-              ",~"w")~
+              ", "w")
               if~file~then~
-                file:write(error~..~" \iow_char:N \\ n ")~
-                file:close()~
+                file:write(error .. " \iow_char:N \\ n ")
+                file:close()
               end~
               print('
                 \iow_char:N \\ \iow_char:N \\ begingroup
@@ -525,58 +323,53 @@
                     { luabridge }
                     { failed-to-execute }
                     { g_luabridge_output_dirname_str }
-                    { g_luabridge_output_dirname_str }
+                    { g_luabridge_error_output_filename_str }
                 \iow_char:N \\ \iow_char:N \\ endgroup
-              ')~
+              ')
             end
           }
-        \immediate \write
-          \l_@@_output_stream
-          { \exp_not:V \l_tmpb_tl }
-        \immediate \closeout
-          \l_@@_output_stream
-        \msg_info:nnVV
+        \iow_now:NV
+          \g_tmpa_iow
+          \l_tmpa_tl
+        \iow_close:N
+          \g_tmpa_iow
+        \msg_info:nnV
           { luabridge }
           { executing-helper-script }
           \g_luabridge_helper_script_filename_str
-          \g_luabridge_standard_output_filename_str
-        \tl_set:Nx
-          \l_tmpa_tl
+        \sys_get_shell:xnNTF
           {
-            texlua~"
+            texlua~
               \g_luabridge_output_dirname_str /
               \g_luabridge_helper_script_filename_str
-            "~>~"
-              \g_luabridge_output_dirname_str /
-              \g_luabridge_standard_output_filename_str
-            "
           }
-        \_luabridge_execute_shell:V
+          { }
           \l_tmpa_tl
-        \file_if_exist_input:VF
-          \g_luabridge_standard_output_filename_str
           {
+            \l_tmpa_tl
+          }
+          {
             \msg_error:nn
               { luabridge }
               { level-disabled }
           }
       }
+    \prg_generate_conditional_variant:Nnn
+      \sys_get_shell:nnN
+      { xnN }
+      { TF }
     \cs_generate_variant:Nn
       \msg_info:nnn
       { nnV }
     \cs_generate_variant:Nn
-      \msg_info:nnnn
-      { nnVV }
-    \cs_generate_variant:Nn
       \msg_error:nnnn
       { nnvv }
     \cs_generate_variant:Nn
-      \_luabridge_execute_shell:n
-      { V }
-    \prg_generate_conditional_variant:Nnn
-      \file_if_exist_input:n
-      { V }
-      { F }
+      \iow_open:Nn
+      { NV }
+    \cs_generate_variant:Nn
+      \iow_now:Nn
+      { NV }
     \msg_new:nnn
       { luabridge }
       { writing-helper-script }
@@ -587,8 +380,7 @@
       { luabridge }
       { executing-helper-script }
       {
-        Executing~a~helper~Lua~script~from~file~#1~
-        and~storing~the~result~in~file~#2
+        Executing~a~helper~Lua~script~from~file~#1
       }
     \msg_new:nnnn
       { luabridge }
@@ -597,9 +389,24 @@
         An~error~was~encountered~while~executing~Lua~code
       }
       {
-        For further clues, examine file #1/#2
+        For further clues, examine file #1 / #2
       }
+    \msg_new:nnnn
+      { luabridge }
+      { level-disabled }
+      {
+        Shell~escape~seems~to~be~disabled
+      }
+      {
+        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
+        --enable-write18~flag,~or~write~shell_escape=t~in~the~
+        texmf.cnf~file.
+      }
   }
+\int_compare:nNnT
+  { \g_luabridge_method_int }
+  =
+  { \c_luabridge_method_directlua_int }
   {
     \cs_new:Nn
       \luabridge_now:n
@@ -610,16 +417,17 @@
         \tl_set:Nx
           \l_tmpb_tl
           {
-            local~function~print(input)~
-              input~=~tostring(input)~
-              local~output~=~{}~
+            _ENV = setmetatable({}, {__index = _ENV})
+            local~function~print(input)
+              input = tostring(input)
+              local~output = {}
               for~line~in~input:gmatch("[^
                     \iow_char:N \\ r
                     \iow_char:N \\ n
-                  ]+")~do~
-                table.insert(output,~line)~
+                  ]+") do~
+                table.insert(output, line)
               end~
-              tex.print(output)~
+              tex.print(output)
             end~
             \exp_not:V \l_tmpa_tl
           }
@@ -653,8 +461,8 @@
 \RequirePackage{expl3}
 \ProvidesExplPackage
   {lt3luabridge}%
-  {2022-06-26}%
-  {1.0.1}%
+  {2022-08-08}%
+  {2.0.0}%
   {An expl3 package that allows you to execute Lua code in LuaTeX or any other
    TeX engine that exposes the shell}
 \input lt3luabridge\relax

Modified: trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.sty	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.sty	2022-08-08 20:59:11 UTC (rev 64077)
@@ -45,8 +45,8 @@
 \RequirePackage{expl3}
 \ProvidesExplPackage
   {lt3luabridge}%
-  {2022-06-26}%
-  {1.0.1}%
+  {2022-08-08}%
+  {2.0.0}%
   {An expl3 package that allows you to execute Lua code in LuaTeX or any other
    TeX engine that exposes the shell}
 \input lt3luabridge\relax

Modified: trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.tex	2022-08-08 20:58:55 UTC (rev 64076)
+++ trunk/Master/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.tex	2022-08-08 20:59:11 UTC (rev 64077)
@@ -47,70 +47,55 @@
 \fi
 \ExplSyntaxOn
 \int_const:Nn
-  \c_luabridge_method_write_eighteen_int
+  \c_luabridge_method_directlua_int
   { 0 }
 \int_const:Nn
-  \c_luabridge_method_os_execute_int
+  \c_luabridge_method_shell_int
   { 1 }
-\int_const:Nn
-  \c_luabridge_method_directlua_int
-  { 2 }
 \int_if_exist:NF
   \g_luabridge_method_int
   {
     \int_new:N
       \g_luabridge_method_int
-    \sys_if_engine_luatex:TF
-      {
-        \int_gset_eq:NN
-          \g_luabridge_method_int
-          \c_luabridge_method_directlua_int
-      }
-      {
-        \int_gset_eq:NN
-          \g_luabridge_method_int
-          \c_luabridge_method_write_eighteen_int
-      }
+      \sys_if_engine_luatex:TF
+        {
+          \int_gset_eq:NN
+            \g_luabridge_method_int
+            \c_luabridge_method_directlua_int
+        }
+        {
+          \int_gset_eq:NN
+            \g_luabridge_method_int
+            \c_luabridge_method_shell_int
+        }
   }
 \msg_new:nnn
   { luabridge }
-  { unknown-method }
+  { method-shell }
   {
-    Unknown~bridging~method:~#1
+    Using~shell~escape~as~the~bridging~method
   }
 \msg_new:nnn
   { luabridge }
-  { method-write-eighteen }
+  { method-directlua }
   {
-    Using~shell~escape~via~write18~as~the~bridging~method
+    Using~direct~Lua~access~as~the~bridging~method
   }
 \msg_new:nnn
   { luabridge }
-  { method-os-execute }
+  { unknown-method }
   {
-    Using~shell~escape~via~os.execute()~as~the~bridging~method
+    Unknown~bridging~method:~#1
   }
-\msg_new:nnn
-  { luabridge }
-  { method-directlua }
-  {
-    Using~direct~Lua~access~as~the~bridging~method
-  }
 \int_case:nnF
   { \g_luabridge_method_int }
   {
-    { \c_luabridge_method_write_eighteen_int }
+    { \c_luabridge_method_shell_int }
       {
         \msg_info:nn
           { luabridge }
-          { method-write-eighteen }
+          { method-shell }
       }
-    { \c_luabridge_method_os_execute_int }
-      {
-        \msg_info:nn
-          { luabridge }
-          { method-os-execute }
-      }
     { \c_luabridge_method_directlua_int }
       {
         \msg_info:nn
@@ -127,101 +112,11 @@
       { unknown-method }
       \g_luabridge_method_int
   }
-\bool_if:nTF
+\int_compare:nNnT
+  { \g_luabridge_method_int }
+  =
+  { \c_luabridge_method_shell_int }
   {
-    \int_compare_p:nNn
-      { \g_luabridge_method_int }
-      =
-      { \c_luabridge_method_write_eighteen_int } ||
-    \int_compare_p:nNn
-      { \g_luabridge_method_int }
-      =
-      { \c_luabridge_method_os_execute_int }
-  }
-  {
-    \int_const:Nn
-      \c__luabridge_level_disabled_int
-      { 0 }
-    \int_const:Nn
-      \c__luabridge_level_enabled_int
-      { 1 }
-    \int_const:Nn
-      \c__luabridge_level_restricted_int
-      { 2 }
-    \int_new:N
-      \l__luabridge_level_int
-    \cs_if_exist:NTF
-      \pdfshellescape
-      {
-        \int_gset:Nn
-          \l__luabridge_level_int
-          { \pdfshellescape }
-      }
-      {
-        \cs_if_exist:NTF
-          \shellescape
-          {
-            \int_gset:Nn
-              \l__luabridge_level_int
-              { \shellescape }
-          }
-          {
-            \int_case:nnF
-              { \g_luabridge_method_int }
-              {
-                { \c_luabridge_method_write_eighteen_int }
-                  {
-                    \int_gset_eq:NN
-                      \l__luabridge_level_int
-                      \c__luabridge_level_enabled_int
-                  }
-              }
-              {
-                \int_gset:Nn
-                  \l__luabridge_level_int
-                  {
-                    \lua_now:n
-                      {
-                        tex.sprint(status.shell_escape or "1")
-                      }
-                  }
-              }
-          }
-      }
-    \msg_new:nnn
-      { luabridge }
-      { unknown-level }
-      {
-        Unknown~shell~escape~level:~#1
-      }
-    \msg_new:nnnn
-      { luabridge }
-      { level-disabled }
-      {
-        Shell~escape~seems~to~be~disabled
-      }
-      {
-        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
-        --enable-write18~flag,~or~write~shell_escape=t~in~the~
-        texmf.cnf~file.
-      }
-    \msg_new:nnn
-      { luabridge }
-      { level-enabled }
-      {
-        Shell~escape~seems~to~be~enabled
-      }
-    \msg_new:nnnn
-      { luabridge }
-      { level-restricted }
-      {
-        Shell~escape~seems~to~be~restricted
-      }
-      {
-        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
-        --enable-write18~flag,~or~write~shell_escape=t~in~the~
-        texmf.cnf~file.
-      }
     \str_const:Nn
       \c_luabridge_default_output_dirname_str
       { . }
@@ -231,80 +126,6 @@
     \str_const:Nx
       \c_luabridge_default_error_output_filename_str
       { \jobname.luabridge.err }
-    \str_const:Nx
-      \c_luabridge_default_standard_output_filename_str
-      { \jobname.luabridge.out }
-    \int_case:nnF
-      { \l__luabridge_level_int }
-      {
-        { \c__luabridge_level_disabled_int }
-          {
-            \msg_warning:nn
-              { luabridge }
-              { level-disabled }
-          }
-        { \c__luabridge_level_enabled_int }
-          {
-            \msg_info:nn
-              { luabridge }
-              { level-enabled }
-          }
-        { \c__luabridge_level_restricted_int }
-          {
-            \msg_warning:nn
-              { luabridge }
-              { level-restricted }
-          }
-      }
-      {
-        \msg_error:nnx
-          { luabridge }
-          { unknown-level }
-          { \l__luabridge_level_int }
-      }
-    \cs_new:Nn
-      \_luabridge_assert_shell_escape:
-      {
-        \int_case:nnF
-          { \l__luabridge_level_int }
-          {
-            { \c__luabridge_level_disabled_int }
-              {
-                \msg_error:nn
-                  { luabridge }
-                  { level-disabled }
-              }
-          }
-      }
-    \int_case:nn
-      { \g_luabridge_method_int }
-      {
-        { \c_luabridge_method_write_eighteen_int }
-          {
-            \cs_new:Nn
-              \_luabridge_execute_shell:n
-              {
-                \_luabridge_assert_shell_escape:
-                \immediate
-                  \write 18
-                    { #1 }
-              }
-          }
-        { \c_luabridge_method_os_execute_int }
-          {
-            \cs_new:Nn
-              \_luabridge_execute_shell:n
-              {
-                \_luabridge_assert_shell_escape:
-                \lua_now:e
-                  {
-                    os.execute(
-                      " \lua_escape:e { #1 } "
-                    )
-                  }
-              }
-          }
-      }
     \str_if_exist:NF
       \g_luabridge_output_dirname_str
       {
@@ -328,20 +149,11 @@
           \g_luabridge_error_output_filename_str
           \c_luabridge_default_error_output_filename_str
       }
-    \str_if_exist:NF
-      \g_luabridge_standard_output_filename_str
-      {
-        \str_gset_eq:NN
-          \g_luabridge_standard_output_filename_str
-          \c_luabridge_default_standard_output_filename_str
-      }
-    \cs:w newwrite \cs_end:
-      \l__luabridge_output_stream
     \cs_new:Nn
       \luabridge_now:n
       {
-        \immediate \openout
-          \l__luabridge_output_stream
+        \iow_open:NV
+          \g_tmpa_iow
           \g_luabridge_helper_script_filename_str
         \msg_info:nnV
           { luabridge }
@@ -353,19 +165,20 @@
         \tl_set:Nx
           \l_tmpb_tl
           {
-            local~ran_ok,~error~=~pcall(function()~
-              local~ran_ok,~kpse~=~pcall(require,~"kpse")~
-              if~ran_ok~then~kpse.set_program_name("luatex")~end~
-              \exp_not:V \l_tmpa_tl~
-            end)~
+            local~ran_ok, error = pcall(function()
+              local~ran_ok, kpse = pcall(require,~"kpse")
+              if~ran_ok~then~kpse.set_program_name("luatex") end~
+              \exp_not:V \l_tmpa_tl
+              \iow_newline:
+            end)
             if~not~ran_ok~then~
-              local~file~=~io.open("
+              local~file = io.open("
                 \g_luabridge_output_dirname_str /
                 \g_luabridge_error_output_filename_str
-              ",~"w")~
+              ", "w")
               if~file~then~
-                file:write(error~..~" \iow_char:N \\ n ")~
-                file:close()~
+                file:write(error .. " \iow_char:N \\ n ")
+                file:close()
               end~
               print('
                 \iow_char:N \\ \iow_char:N \\ begingroup
@@ -374,58 +187,53 @@
                     { luabridge }
                     { failed-to-execute }
                     { g_luabridge_output_dirname_str }
-                    { g_luabridge_output_dirname_str }
+                    { g_luabridge_error_output_filename_str }
                 \iow_char:N \\ \iow_char:N \\ endgroup
-              ')~
+              ')
             end
           }
-        \immediate \write
-          \l__luabridge_output_stream
-          { \exp_not:V \l_tmpb_tl }
-        \immediate \closeout
-          \l__luabridge_output_stream
-        \msg_info:nnVV
+        \iow_now:NV
+          \g_tmpa_iow
+          \l_tmpa_tl
+        \iow_close:N
+          \g_tmpa_iow
+        \msg_info:nnV
           { luabridge }
           { executing-helper-script }
           \g_luabridge_helper_script_filename_str
-          \g_luabridge_standard_output_filename_str
-        \tl_set:Nx
-          \l_tmpa_tl
+        \sys_get_shell:xnNTF
           {
-            texlua~"
+            texlua~
               \g_luabridge_output_dirname_str /
               \g_luabridge_helper_script_filename_str
-            "~>~"
-              \g_luabridge_output_dirname_str /
-              \g_luabridge_standard_output_filename_str
-            "
           }
-        \_luabridge_execute_shell:V
+          { }
           \l_tmpa_tl
-        \file_if_exist_input:VF
-          \g_luabridge_standard_output_filename_str
           {
+            \l_tmpa_tl
+          }
+          {
             \msg_error:nn
               { luabridge }
               { level-disabled }
           }
       }
+    \prg_generate_conditional_variant:Nnn
+      \sys_get_shell:nnN
+      { xnN }
+      { TF }
     \cs_generate_variant:Nn
       \msg_info:nnn
       { nnV }
     \cs_generate_variant:Nn
-      \msg_info:nnnn
-      { nnVV }
-    \cs_generate_variant:Nn
       \msg_error:nnnn
       { nnvv }
     \cs_generate_variant:Nn
-      \_luabridge_execute_shell:n
-      { V }
-    \prg_generate_conditional_variant:Nnn
-      \file_if_exist_input:n
-      { V }
-      { F }
+      \iow_open:Nn
+      { NV }
+    \cs_generate_variant:Nn
+      \iow_now:Nn
+      { NV }
     \msg_new:nnn
       { luabridge }
       { writing-helper-script }
@@ -436,8 +244,7 @@
       { luabridge }
       { executing-helper-script }
       {
-        Executing~a~helper~Lua~script~from~file~#1~
-        and~storing~the~result~in~file~#2
+        Executing~a~helper~Lua~script~from~file~#1
       }
     \msg_new:nnnn
       { luabridge }
@@ -446,9 +253,24 @@
         An~error~was~encountered~while~executing~Lua~code
       }
       {
-        For further clues, examine file #1/#2
+        For further clues, examine file #1 / #2
       }
+    \msg_new:nnnn
+      { luabridge }
+      { level-disabled }
+      {
+        Shell~escape~seems~to~be~disabled
+      }
+      {
+        You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
+        --enable-write18~flag,~or~write~shell_escape=t~in~the~
+        texmf.cnf~file.
+      }
   }
+\int_compare:nNnT
+  { \g_luabridge_method_int }
+  =
+  { \c_luabridge_method_directlua_int }
   {
     \cs_new:Nn
       \luabridge_now:n
@@ -459,16 +281,17 @@
         \tl_set:Nx
           \l_tmpb_tl
           {
-            local~function~print(input)~
-              input~=~tostring(input)~
-              local~output~=~{}~
+            _ENV = setmetatable({}, {__index = _ENV})
+            local~function~print(input)
+              input = tostring(input)
+              local~output = {}
               for~line~in~input:gmatch("[^
                     \iow_char:N \\ r
                     \iow_char:N \\ n
-                  ]+")~do~
-                table.insert(output,~line)~
+                  ]+") do~
+                table.insert(output, line)
               end~
-              tex.print(output)~
+              tex.print(output)
             end~
             \exp_not:V \l_tmpa_tl
           }



More information about the tex-live-commits mailing list.