[luatex] LUA_INIT mechanism in texlua?
Taco Hoekwater
taco at bittext.nl
Thu Jun 2 10:26:59 CEST 2022
> On 2 Jun 2022, at 09:51, jfbu <jfbu at free.fr> wrote:
>
> [sending from correct address jfbu at free.fr, please use it if replying]
> Hi,
>
> Afer reading https://www.lua.org/manual/5.1/lua.html I learned about LUA_INIT.
>
> I have tested it and it works with my lua binary but not with texlua.
LUA_INIT is a standalone lua interpreter feature that is not present in texlua (which is itself a symlink to luatex, btw).
Neither are the other ‘lua’ executable command line options, except for the use of the global ‘arg’ variable.
To get a similar effect, you could use:
#!/usr/bin/env texlua
assert(loadstring(os.getenv("LUA_INIT") or ''))()
foo = foo or "bonjour"
print(foo)
Best wishes,
Taco
> For my test with lua I used this file with the executable bit on:
>
> ---
> #!/usr/bin/env lua
>
> foo = foo or "bonjour"
>
> print(foo)
> ---
>
> Then (in a bash shell):
>
> export LUA_INIT="foo=\"Guten Tag\""
> ./test.lua
> Guten Tag
>
> Now, a copy of the file above but using "/usr/bin/env texlua" in place of "lua" does not act the same:
>
> ./test.texlua
> bonjour
> echo $LUA_INIT
> foo="Guten Tag"
>
> I checked the manpage of texlua (which is the one of luatex) and see no mention.
>
> I searched the lua.pdf documentation for string _INIT and found nothing.
>
> Is there some replacement for LUA_INIT functionality?
>
> Rationale of my question: I was looking into LaTeX3 documentation and wanted
> to typeset some of it including implementation. After some quick digging
> I understood that the l3build script has a variable
> typesetcmds and I first tried to set it on command line but I learned that
> it is probably not possible, then I read about LUA_INIT in the Lua documentation
> as mentioned above,
> which would be nice if it worked with l3build too (i.e. with texlua).
>
> I would be happy to be allowed to do (bash shell) something such as
>
> env TEXLUA_INIT='typesetcmds=""' l3build doc
>
> rather than having to modify a file (either a l3build config or a dtx file)
> which sorts of pushes me into rebasing a branch on each pull from upstream.
>
> Please CC jfbu if replying
> Best,
> Jean-François
—
Taco Hoekwater E: taco at bittext.nl
genderfluid (all pronouns)
More information about the luatex
mailing list.