From 0554aa19167d66f4a8bbfce0ea9ef8e50a614718 Mon Sep 17 00:00:00 2001 From: Laurent Figadere Date: Wed, 11 Apr 2018 16:47:52 +0200 Subject: [PATCH] Improvement proposal: when unuse option is used unload all modules in this path Changes to be committed: modified: modulecmd.tcl.in --- modulecmd.tcl.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 8da9c63fe..343894492 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -5860,6 +5860,21 @@ proc cmdModuleUnuse {args} { } if {$unusepath ne ""} { + if {[lsearch -exact $modpathlist $unusepath] >= 0} { + set loadedmodlist [lreverse [getLoadedModuleList]] + foreach mod $loadedmodlist { + set modfile [getPathToModule $mod] + if { [string match $unusepath/* $modfile] } { + reportWarning "Unloading $mod" + set ret [eval cmdModuleUnload "match" $mod] + # sub-module interpretation failed, raise error + if {$ret} { + set errormsg "SUB_FAILED" + } + } + } + } + pushMode "unload" catch { unload-path MODULEPATH $unusepath