From a1821a961b99701c0faa12ff53f97cd4b8ebdfac Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 15 May 2019 15:01:48 +0200 Subject: [PATCH 1/2] fixes --- Pmodules/libmodules.tcl | 26 ++++++++++++++++---------- Pmodules/modulecmd.bash.in | 3 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Pmodules/libmodules.tcl b/Pmodules/libmodules.tcl index 38f4b55..e898051 100644 --- a/Pmodules/libmodules.tcl +++ b/Pmodules/libmodules.tcl @@ -68,21 +68,27 @@ proc module-addgroup { group } { debug "no orphan modules to unload" } debug "mode=remove: $env(MODULEPATH)" - remove-path MODULEPATH [file join \ - $::PmodulesRoot \ - $group \ - $::PmodulesModulfilesDir \ - {*}$::variant] + set dir [file join \ + $::PmodulesRoot \ + $group \ + $::PmodulesModulfilesDir \ + {*}$::variant] + debug "mode=remove: dir=$dir" + remove-path MODULEPATH $dir debug "mode=remove: $env(UsedGroups)" remove-path UsedGroups $group + debug "mode=remove: $env(UsedGroups)" } if { [module-info mode switch2] } { debug "mode=switch2" - append-path MODULEPATH [file join \ - $::PmodulesRoot \ - $group \ - $::PmodulesModulfilesDir \ - [module-info name]] + set dir [file join \ + $::PmodulesRoot \ + $group \ + $::PmodulesModulfilesDir \ + [module-info name]] + if { [file isdirectory $dir] } { + append-path MODULEPATH $dir + } append-path UsedGroups ${group} } } diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index a52ba79..2b9cef5 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -670,8 +670,7 @@ subcommand_load() { current_modulefile="${array[0]}" prefix="${array[1]}" test -n "${current_modulefile}" || return 1 - get_release release "${current_modulefile}" - [[ :${UsedReleases}: =~ ${release} ]] + get_release release "${current_modulefile}" "${UsedReleases}" } # From 05338d25b4dc044b748cd12eff4138c097c76d2e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 15 May 2019 16:16:36 +0200 Subject: [PATCH 2/2] update of PMODULES_ENV fixed in subcommand 'unload' Not all cached data has been updated while unloading a module amangst other the list of used groups (UsedGroups) --- Pmodules/modulecmd.bash.in | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 2b9cef5..f6f49c9 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -864,10 +864,30 @@ subcommand_unload() { # another module. # For the time being the modules requiring this module will be # unloaded too. + local opts=() + pmodules::get_options opts -- '' "$@" || subcommand_help_${subcommand} + eval set -- "${opts[@]}" + local args=() while (( $# > 0 )); do - subcommand_generic1 unload "$1" + case $1 in + -- ) + ;; + * ) + args+=( "$1" ) + ;; + esac shift done + if (( ${#args[@]} == 0 )); then + std::die 3 "%s %s: missing argument\n" \ + "${CMD}" 'unload' + fi + + for arg in "${args[@]}"; do + local output=$("${modulecmd}" "${g_shell}" "${subcommand}" "${arg}") + echo "${output}" + eval "${output}" + done } #