Hi Paul,
There is an issue opened for this feature request [1], Do not hesitate to
update it with this code change. A pull request would also be welcomed.
Regards,
Xavier
[1] https://github.com/cea-hpc/modules/issues/424
Le ven. 8 avr. 2022 à 17:35, Paul Markfort <pau...@gm...> a écrit :
> From the module man page:
> source scriptfile...
> Execute scriptfile into the shell environment. scriptfile
> must
> be written with modulefile syntax and specified with a
> fully
> qualified path. Once executed scriptfile is not marked
> loaded in
> shell environment which differ from load sub-command.
>
>
>
>
> Could it be changed to find the modulefile just like module load.
> This could be very handy when putting together user environment
> initialization scripts (bashrc, cshrc).
>
> Instead of:
> module --silent source "${MODULESHOME}/common/base/all"
> I could use:
> module --silent source "base/all"
> (which is a lot cleaner, and easier to maintain - particularly if I decide
> to move the modulefile tree).
>
>
> The particular module sets aliases, and loads other modules (if needed).
>
> I suspect this could be very useful to others as well.
>
>
> I have been able to make this work by modifying module.tcl (5.01) as
> follows:
>
>
> < set absfpath [getAbsolutePath $fpath]
> ---
> > ### paulfm allow source to find modules like load does
> > lassign [getPathToModule $fpath] s_modfile s_modname s_modnamevr
> > set absfpath [getAbsolutePath $s_modfile]
> > # set absfpath [getAbsolutePath $fpath]
>
>
>
> The full modified function looks like this:
>
> proc cmdModuleSource {mode args} {
> reportDebug $args
> foreach fpath $args {
> ### paulfm allow source to find modules like load does
> lassign [getPathToModule $fpath] s_modfile s_modname s_modnamevr
> set absfpath [getAbsolutePath $s_modfile]
> # set absfpath [getAbsolutePath $fpath]
> if {$fpath eq {}} {
> reportErrorAndExit {File name empty}
> } elseif {[file exists $absfpath]} {
> lappendState mode $mode
> # sourced file must also have a magic cookie set at their start
> execute-modulefile $absfpath $absfpath $absfpath $absfpath 0 0
> lpopState mode
> } else {
> reportErrorAndExit "File $fpath does not exist"
> }
> }
> }
>
>
>
>
> --
> --------------------------------------------------------
> The views and opinions expressed above are strictly
> those of the author(s). The content of this message has
> not been reviewed nor approved by any entity whatsoever.
> --------------------------------------------------------
> Paul FM Info: http://paulfm.com/~paulfm/
> --------------------------------------------------------
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
|