Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get numeric error-level from os.execute #333

Closed

Conversation

muzimuzhi
Copy link
Contributor

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.

`os.execute` in Lua 5.2 or newer returns 3 results, rather than 1, in which
the first is no longer a number.
@muzimuzhi
Copy link
Contributor Author

muzimuzhi commented Jan 2, 2024

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.

@muzimuzhi muzimuzhi closed this Jan 2, 2024
@muzimuzhi muzimuzhi deleted the fix/errorlevel-of-os.execute branch January 2, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant