Repository navigation
Conversation
Since TACC#820 a failed load emits a multi-line __LMOD_LAST_ERROR. For csh the newlines were left unescaped, so csh's eval `...` split them into extra words and setenv failed with "Too many arguments", which aborts a csh script. Bash was unaffected. Csh.expandVar() now stores __LMOD_LAST_ERROR with newlines as "\n" (and "\" as "\\"), and LastError() decodes them under csh so "module last-error" still prints the full message. Any other value containing newlines has them collapsed to blanks rather than breaking setenv. Add rt/csh_error: a tcsh script loads a missing module, runs last-error, then loads a real module; it fails if the script aborts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
|
Thanks for the patch. You are correct that the issue was with __LMOD_LAST_ERROR and your solution works. However I have decided to use a base64 encoding of __LMOD_LAST_ERROR and decode it when printing the error out when |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #867.
Problem
Since #820 (
module last-error), a failed load emits__LMOD_LAST_ERRORholding the multi-line error message.Csh.expandVar()escapes blanks and special characters but not newlines, so the csh output is asetenvsplit across several lines. csh'seval `...`turns those newlines into word breaks, sosetenvgets too many arguments:In a csh/tcsh script that error is fatal, so the script stops at the failed
module load. Before #820 onlyfalsewas emitted, which just set$status. Bash quotes newlines correctly and was unaffected. Lmod 9.4.3, 9.4.4 and 9.4.5 are affected.Fix
shells/Csh.lua: for__LMOD_LAST_ERROR, store newlines as\nand backslashes as\\, so it is a single validsetenv. Any other value that contains a newline has it collapsed to an escaped blank rather than breakingsetenv.src/cmdfuncs.lua: under csh,LastError()decodes those escapes, somodule last-errorstill prints the full multi-line message.csh cannot carry a newline through
eval `...`at all (tried backtickprintf, a literal\n, and a newline stored in a variable), so encoding and decoding is needed to keep the message. Bash output is unchanged.Test
New
rt/csh_error: a tcsh script loads a missing module and prints$status, runslast-error, then loads a real module and prints a completion line.setenv: Too many arguments., so the test fails.last-errorshows the full multi-line message.The existing
rttests compare the text Lmod emits but don't check that the shell accepts it, andcsh_swapnever takes an error path, which is how this got through.Local test run (macOS arm64, Lua 5.5.1, luaposix 37.0)
tm .: 158 passed, 11 diffs. The 11 (avail_termwidth,configDir,help,lars,load,modulerc,saverestore,sd_tacc,sitePkg,tacc,termWidthFallback) diff the same way on unmodifiedmain, with byte-identical generated output, so they come from this machine's setup (TCL interpreter detection, theshasumpath, nolua-term,PATH), not from this change.Also verified by patching an installed 9.4.3: tcsh and csh scripts continue after a failed load with
status=1, andmodule last-errorprints the full message.🤖 Generated with Claude Code