summaryrefslogtreecommitdiff
path: root/macros/generic/lt3luabridge/lt3luabridge.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/lt3luabridge/lt3luabridge.dtx')
-rw-r--r--macros/generic/lt3luabridge/lt3luabridge.dtx87
1 files changed, 77 insertions, 10 deletions
diff --git a/macros/generic/lt3luabridge/lt3luabridge.dtx b/macros/generic/lt3luabridge/lt3luabridge.dtx
index 67cc73c738..d8bb7a3bee 100644
--- a/macros/generic/lt3luabridge/lt3luabridge.dtx
+++ b/macros/generic/lt3luabridge/lt3luabridge.dtx
@@ -47,7 +47,7 @@
% }^^A
% }
%
-% \date{Released 2024-02-14}
+% \date{Released 2024-07-03}
%
% \maketitle
%
@@ -151,7 +151,7 @@
% \texttt{-output-directory} parameter of the \TeX{} engine.
% \end{variable}
%
-% \begin{variable}[added = 2022-06-26]{\c_luabridge_default_output_dirname_str}
+% \begin{variable}[added = 2022-06-26, updated = 2024-07-03]{\c_luabridge_default_output_dirname_str}
% This constant is the default value of \cs{g_luabridge_output_dirname_str}.
% \end{variable}
%
@@ -261,9 +261,42 @@
=
{ \c_luabridge_method_shell_int }
{
- \str_const:Nn
- \c_luabridge_default_output_dirname_str
- { . }
+% \end{macrocode}
+%
+% Instead of assuming the current working directory as the output directory,
+% try to determine the output directory from the environmental variable
+% \texttt{TEXMF_OUTPUT_DIRECTORY}, which is automatically defined by \TeX{}
+% engines and accessible from child processes.
+%
+% \begin{macrocode}
+ \sys_if_platform_unix:TF
+ {
+ \str_const:Nn
+ \c_luabridge_default_output_dirname_str
+ { $TEXMF_OUTPUT_DIRECTORY }
+ }
+ {
+ \sys_if_platform_windows:TF
+ {
+ \str_set:Nn
+ \l_tmpa_str
+ { TEXMF_OUTPUT_DIRECTORY }
+ \str_put_left:NV
+ \l_tmpa_str
+ \c_percent_str
+ \str_put_right:NV
+ \l_tmpa_str
+ \c_percent_str
+ \str_const:NV
+ \c_luabridge_default_output_dirname_str
+ \l_tmpa_str
+ }
+ {
+ \str_const:Nn
+ \c_luabridge_default_output_dirname_str
+ { . }
+ }
+ }
\str_const:Nx
\c_luabridge_default_helper_script_filename_str
{ \jobname.luabridge.lua }
@@ -358,9 +391,43 @@
\g_luabridge_helper_script_filename_str
\sys_get_shell:xnNTF
{
- texlua~
- \g_luabridge_output_dirname_str /
- \g_luabridge_helper_script_filename_str
+% \end{macrocode}
+%
+% If the environmental variable \texttt{TEXMF_OUTPUT_DIRECTORY} is undefined,
+% use the current working directory (\texttt{.}) instead.
+%
+% \begin{macrocode}
+ \str_if_eq:NNTF
+ \g_luabridge_output_dirname_str
+ \c_luabridge_default_output_dirname_str
+ {
+ \sys_if_platform_windows:TF
+ {
+ if~not~defined~TEXMF_OUTPUT_DIRECTORY~(
+ texlua~
+ \g_luabridge_helper_script_filename_str
+ )~else~(
+ texlua~
+ \g_luabridge_output_dirname_str /
+ \g_luabridge_helper_script_filename_str
+ )
+ }
+ {
+ \sys_if_platform_unix:T
+ {
+ TEXMF_OUTPUT_DIRECTORY =
+ ${TEXMF_OUTPUT_DIRECTORY:-.} \iow_newline:
+ }
+ texlua~
+ \g_luabridge_output_dirname_str /
+ \g_luabridge_helper_script_filename_str
+ }
+ }
+ {
+ texlua~
+ \g_luabridge_output_dirname_str /
+ \g_luabridge_helper_script_filename_str
+ }
}
{ }
#1
@@ -492,8 +559,8 @@
\RequirePackage{expl3}
\ProvidesExplPackage
{lt3luabridge}%
- {2024-02-14}%
- {2.1.0}%
+ {2024-07-03}%
+ {2.2.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