Many thanks Laurent for your analysis.
I have created a ticket to fix this issue that is still present on
latest version:
https://github.com/envmodules/modules/issues/565
>From what I understand, the bracket characters should be espaced when
producing output for csh/tcsh shells.
Laurent you see the $osrel variable not replace maybe because you
define the alias content between curly braces (that inhibit variable
expansion).
In the mean time Andreas, I suggest you to use the puts command to
manually craft the shell code:
#%Module
set osrel 80
puts stdout "alias mycommand bsub\\ -R\\ \"select\\\[type==X64LIN &&
osrel==$osrel\\\]\"\\ myapp;"
Best regards,
Xavier
Le mer. 29 janv. 2025 à 14:52, Laurent BESSON
<lau...@ea...> a écrit :
>
> 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...>
> Envoyé : mercredi 29 janvier 2025 10:49
> À : 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:
>
> [...]
>
> \[...\]
>
> {[...]}
>
> {\[...\]}
>
> {\\[...\\]}
>
> {\\\[...\\\]}
>
> "[...]"
> "\[...\]"
> "\\[...\\]"
> "\\\[...\\\]"
>
> 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
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|