Conversation
| -- Check return code first. We don't want source_sh to raise an LmodError, we just print | ||
| -- an LmodWarning stating we couldn't do a proper version compatibility check | ||
| local rc = os.execute("bash -c 'source " .. script .. "'") | ||
| if rc == 0 then |
There was a problem hiding this comment.
For me this does not seem to work. Even though the script exists, the condition always evaluates to false. By adding some debugging statements, I found that rc is a boolean (or nil?), and if rc then works for me.
There was a problem hiding this comment.
https://www.lua.org/pil/22.2.html is not really clear, but my AI friend told me:
In Lua, os.execute() returns different values depending on the Lua version.
✅ Lua 5.2 and newer (5.2, 5.3, 5.4)
os.execute(command) returns three values:
success, exit_type, code = os.execute("your_command")Meaning:
success → true if the command terminated normally, nil otherwise
exit_type → string:
"exit" → program exited normally
"signal" → program was killed by a signal (Unix)
code → numeric:
exit status (if "exit")
signal number (if "signal")
There was a problem hiding this comment.
Lua 5.1 apparently does only return a number...
💡 Portable pattern
If you want code that works across versions:
local r1, r2, r3 = os.execute(cmd) if type(r1) == "number" then -- Lua 5.1 local exit_code = r1 / 256 else -- Lua 5.2+ local success = r1 local exit_code = r3 end
There was a problem hiding this comment.
This file will have to be added to the following list to ensure that it gets deployed to cvmfs:
https://github.com/EESSI/software-layer-scripts/blob/main/install_scripts.sh#L210
Fixes #189
First step to fixing #201
Unblocks #200 , which blocks EESSI/software-layer#1462 which blocks EESSI/software-layer#1453 ...
This PR can be modified by modifying the
create_lmodsitepackage.pywith something like: