Hello Liam,
This set-alias change occurred on version 4.0 [1]. The goal was to make
set-alias consistent: making an alias and only an alias.
I see that I need to update the set-alias documentation in the man-page
[2], as it still refer to the behavior of version 3.2.
Since version 4.2 set-function enables to define shell functions.
As you say the function definition has to be written in target shell's
syntax, but it is also true for alias definition. Hopefully an alias can be
implemented as a shell function with very simple shell code that can work
over different kind of shells.
However if code has to be specific for every supported shells, some Tcl
code like the following could help to provide a specific definition for
each supported shell within a single modulefile:
switch -- [module-info shelltype] {
sh {
set-function foo {sh code here}
}
csh {
set-alias foo {csh code here}
}
fish {
set-function foo {fish code here}
}
}
Regards,
Xavier
[1]
https://modules.readthedocs.io/en/stable/changes.html#modules-specific-tcl-commands
[2] https://modules.readthedocs.io/en/stable/modulefile.html#mfcmd-set-alias
Le ven. 29 juil. 2022 à 21:03, Gretton, Liam <lia...@le...>
a écrit :
> We're using Modules 4.2.1 on a HPC system.
>
>
>
> Using set-alias in a module always creates an alias in the target shell
> (bash mostly in our case), but that doesn't work for non-interactive
> shells; the alias is defined but without (for bash) shopt -s
> expand_aliases being executed, they're not usable.
>
>
>
> The manpage states that set-alias will set an alias or function. Is there
> a way to force it to create a function instead of an alias?
>
>
>
> set-function isn't much use as the definition has to be written in the
> target shell's syntax, and one of the benefits of using module files is
> that they're shell-agnostic.
>
>
>
> I'm fairly certain this is new behaviour for 4.2.1 or thereabouts. Until
> about a year ago we were running an older version of modulefiles and I'm pretty
> certain we didn't get this problem.
>
>
>
> Thanks,
>
>
> Liam
>
|