[Modules] module source
Manage your shell environment variables and aliases
Brought to you by:
leomania,
xdelaruelle
From: Paul M. <pau...@gm...> - 2022-04-08 15:35:11
|
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/ -------------------------------------------------------- |