I did not run a full regression test but by modifying 2 lines inside modulecmd.tcl like this :
proc charEscaped {str {charlist " \\\\\t{}\[\]|<>!;#^\$&*?\"'`()"}} {
return [regsub -all "\(\[$charlist\]\)" $str {\\\1}]
}
proc charUnescaped {str {charlist " \\\\\t{}\[\]|<>!;#^\$&*?\"'`()"}} {
return [regsub -all "\\\\\(\[$charlist\]\)" $str {\1}]
}
I’m able to define the alias properly.
However, I’ve seen another issue as the $osrel variable was not replaced by its value. Maybe this is intended ? I’ll let Xavier comment on this.
Best regards,
Laurent.
De : Laurent BESSON <lau...@ea...>
Envoyé : mercredi 29 janvier 2025 11:21
À : Environment Modules usage and discussion. <mod...@li...>
Objet : Re: [Modules] aliases with square brackets in tcsh and modules 4.8.0
Hello,
Good news : I did reproduce your issue
Bad news : I see the same behaviour (not saying bug yet !) with version 5.5.0
If you just launch :
/usr/bin/tclsh ‘<path to your module version>/libexec/modulecmd.tcl' tcsh load <your module>
You will see what actually real alias command is computed by module.
With this line in the module :
set-alias mycommand {bsub -R "select\[type==X64LIN \&\& osrel==$osrel]" myapp}
I get this alias :
alias mycommand bsub\ -R\ \"select\\[type==X64LIN\ \\\&\\\&\ osrel==\$osrel]\"\ myapp;
It seems Module sees the « \ » and escape it adding another « \ ». But it does not do it for the square bracket itself.
At the end, I would say it is a bug inside Module.
Dear community, what do you think ?
BR,
Laurent.
De : Andreas Frank <af...@me...<mailto:af...@me...>>
Envoyé : mercredi 29 janvier 2025 10:49
À : mod...@li...<mailto:mod...@li...>
Objet : [Modules] aliases with square brackets in tcsh and modules 4.8.0
Hello,
we are currently trying to migrate from Modules 3.2.12 to 4.8.0.
Environment is RedHat 8 & 9, shell is tcsh.
We do not have the option to switch to anything else currently.
I need to have something like
> set osrel 80
> set-alias mycommand "bsub -R \"select[type==X64LIN && osrel==$osrel]\" myapp"
However, no matter what kind of escaping and quoting I apply (or none at all), I always end up with tcsh complaining:
alias: No match.
It seems the square brackets end up unescaped and unquoted in the tcsh alias command, no matter what I try. Resulting in a failing shell pattern match which is not what I want of course.
I tried:
[...]
\[...\]
{[...]}
{\[...\]}
{\\[...\\]}
{\\\[...\\\]}
"[...]"
"\[...\]"
"\\[...\\]<file://[.../%5d>"
"\\\[...\\\]<file:///[.../%5d>"
and probably some more, all without success.
Is there a way to get this working in 4.8.0? Is it a bug that's maybe fixed in newer versions (which I currently cannot test unfortunately)?
Any help would be greatly appreciated.
Andreas
|