Skip to content

Commit

Permalink
Fix 'is-loaded' to handle list of mods as arg
Browse files Browse the repository at this point in the history
Align behavior on other is-* commands and man-page: return 1 if at least
one arg matches, return 0 elsewhere.
  • Loading branch information
xdelaruelle committed Dec 1, 2017
1 parent cf6b441 commit 2058b52
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions modulecmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -2077,18 +2077,15 @@ proc unset-alias {alias} {
return {}
}

proc is-loaded {modulelist} {
reportDebug "is-loaded: $modulelist"
proc is-loaded {args} {
reportDebug "is-loaded: $args"

if {[llength $modulelist] > 0} {
foreach arg $modulelist {
if {[getLoadedMatchingName $arg "returnfirst"] ne ""} {
return 1
}
foreach mod $args {
if {[getLoadedMatchingName $mod "returnfirst"] ne ""} {
return 1
}
return 0
}
return 1
return 0
}

proc conflict {args} {
Expand Down Expand Up @@ -2126,7 +2123,7 @@ proc prereq {args} {
reportDebug "prereq: ($args) mode = $mode"

if {$mode eq "load"} {
if {![is-loaded $args]} {
if {![eval is-loaded $args]} {
set errMsg "WARNING: $currentModule cannot be loaded due to\
missing prereq."
# adapt error message when multiple modules are specified
Expand Down

0 comments on commit 2058b52

Please sign in to comment.