latex3 / l3build

A testing and building system for LaTeX
LaTeX Project Public License v1.3c
84 stars 14 forks source link

Get numeric error-level from `os.execute` #333

Closed muzimuzhi closed 6 months ago

muzimuzhi commented 6 months ago

This PR makes sure l3build gets an numeric error-level from os.execute().

Background

Till Lua 5.1.x, os.execute() returns only one result which represents status code.

Starting from Lua 5.2, os.execute() returns 3 results, among which the first result is either true or nil, thus it can no longer be used as numeric errorlevel in l3build.

See Lua 5.2 Reference Manual, 8.2 – Changes in the Libraries

Function os.execute now returns true when command terminates successfully and nil plus error information otherwise.

Full doc of os.execute() in Lua 5.3, the Lua version that latest LuaTeX (hence texlua) uses.

os.execute ([command]) This function is equivalent to the ISO C function system. It passes command to be executed by an operating system shell. Its first result is true if the command terminated successfully, or nil otherwise. After this first result the function returns a string plus a number, as follows:

  • "exit": the command terminated normally; the following number is the exit status of the command.
  • "signal": the command was terminated by a signal; the following number is the signal that terminated the command. When called without a command, os.execute returns a boolean that is true if a shell is available.
muzimuzhi commented 6 months ago

Oh, os.execute() from texlua still returns a single, numeric result.

I found a related mailing list thread https://tug.org/pipermail/luatex/2015-November/005536.html .

Update: From the latest reimplementation of os.execute in LuaTeX source (in order to take shell-escape state into account), yes os.execute provided by LuaTeX still returns a single result.