diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index a91cc775..b8b5d7f8 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -968,7 +968,7 @@ proc resolvStringWithEnv {0str} { if {[info exists ::env(${0varname})]} { set ${0varname} $::env(${0varname}) } else { - set ${0varname} "" + set ${0varname} "" } } } diff --git a/testsuite/modules.10-use/030-use.exp b/testsuite/modules.10-use/030-use.exp index 329e455f..f672def2 100644 --- a/testsuite/modules.10-use/030-use.exp +++ b/testsuite/modules.10-use/030-use.exp @@ -116,6 +116,30 @@ set ::env(MODULEPATH) "$mod_path" # list currently enabled paths testouterr_cmd "ALL" "$use" "OK" "$path_list_header\n $path\n $ORIG" +# +# Test variable resolution +# + +# setup value with multiple occurencies of same variable +set var_path "/apps/\$OS/\$MACHINE/\$OS" +set os $tcl_platform(os) +set machine $tcl_platform(machine) +if { $verbose > 0 } { + send_user "\tSetup MODULEPATH = '$var_path'\n" +} +set ::env(MODULEPATH) "$var_path" + +# tests when variable are defined or not +# Currenlty if variable is not defined, directory level is omitted. Should +# preferably skip path element if one variable referred is undefined (to be +# fixed in next major release v5.0) +testouterr_cmd "sh" "$use" "OK" "$path_list_header\n /apps" +set ::env(OS) $os +testouterr_cmd "sh" "$use" "OK" "$path_list_header\n /apps/$os/$os" +set ::env(MACHINE) $machine +testouterr_cmd "sh" "$use" "OK" "$path_list_header\n /apps/$os/$machine/$os" + + if { $verbose > 0 } { send_user "\tRestore MODULEPATH = $ORIG\n" } @@ -133,6 +157,11 @@ testouterr_cmd "ALL" "$use " "ERR" "$empty_use" # Cleanup # +unset os +unset machine +unset env(OS) +unset env(MACHINE) + unset path unset tsdirname unset relpath