Skip to content

Conversation

@azeno
Copy link

@azeno azeno commented Feb 17, 2025

No description provided.

print(cmd)
end
if os.execute(cmd) == 0 then table.insert(objs, cfile..".o") end
if os.execute(cmd) then table.insert(objs, cfile..".o") end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a change of semantics of os.execute in lua? As far as I know, programs return 0 when they execute correctly and a non-zero value when they don't.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was also super confused about that one. That they changed something like this. Did a print(os.execute(cmd)) and it printed true to the console.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does os.execute(cmd) == 0 return false or did lua somehow hacked their logic to support both?

I'm asking because there are other scripts in this repo that use the former logic, and thus might need to be updated.

Copy link
Member

@Kryptos-FR Kryptos-FR Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a change from version 5.2.

Before: https://www.lua.org/manual/5.1/manual.html#pdf-os.execute

This function is equivalent to the C function system. It passes command to be executed by an operating system shell. It returns a status code, which is system-dependent. If command is absent, then it returns nonzero if a shell is available and zero otherwise.

After: https://www.lua.org/manual/5.2/manual.html#pdf-os.execute

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 and 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.

So we should add a comment that it must be executed with a version 5.2+.

@xen2 xen2 merged commit e615840 into stride3d:master Mar 4, 2025
1 check passed
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.

3 participants