From 4176cb3f352b27dc3846c5afe26ff164b6bedf9c Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 1 Apr 2018 13:46:31 +0200 Subject: [PATCH 01/28] ts: empty mod cmd call check in 50/151-module-onlytop --- testsuite/modulefiles/modbad/empty | 31 ++++ .../modules.50-cmds/151-module-onlytop.exp | 7 + testsuite/modules.90-avail/070-full.exp | 166 +++++++++--------- 3 files changed, 121 insertions(+), 83 deletions(-) create mode 100644 testsuite/modulefiles/modbad/empty diff --git a/testsuite/modulefiles/modbad/empty b/testsuite/modulefiles/modbad/empty new file mode 100644 index 000000000..c1b96bb75 --- /dev/null +++ b/testsuite/modulefiles/modbad/empty @@ -0,0 +1,31 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: modbad/%M% +# Revision: %I% +# First Edition: 2018/04/01 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# test behavior against a modulefile using module sub-commands +# only reachable from command line +# }C% +# +############################################################################## + +module {} +module append-path FOO bar +module prepend-path FOO bar +module remove-path FOO bar +module autoinit diff --git a/testsuite/modules.50-cmds/151-module-onlytop.exp b/testsuite/modules.50-cmds/151-module-onlytop.exp index 987492186..d1464c68a 100644 --- a/testsuite/modules.50-cmds/151-module-onlytop.exp +++ b/testsuite/modules.50-cmds/151-module-onlytop.exp @@ -37,6 +37,13 @@ set moderr "$moderr_msgs: module: Invalid command 'foo'\n In '$modulefilere'\n$ testouterr_cmd_re "sh" "load $module" "ERR" "$moderr" testouterr_cmd_re "sh" "display $module" "ERR" "$modlin\n$modulefilere:\n\n$moderr\n$modlin" +set module "modbad/empty" +set modulefilere "$modpathre/$module" +set moderr "$moderr_msgs: module: Command 'help' not supported\n In '$modulefilere'\n$err_contact" + +testouterr_cmd_re "sh" "load $module" "ERR" "$moderr" +testouterr_cmd_re "sh" "display $module" "ERR" "$modlin\n$modulefilere:\n\n$moderr\n$modlin" + # # Cleanup diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 1fbfec66e..883ed69a7 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -41,89 +41,89 @@ set len [string length $modpath] set lrep [expr {($test_cols - $len - 2)/2}] set rrep [expr {$test_cols - $len - 2 - $lrep}] set ts_sh "[string repeat {-} $lrep] $modpath [string repeat {-} $rrep] -alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-saved spread/7.0 -alias/2.0 info/type loc_sym/alias2 modbad/is-used spread/8.0 -append/0.1 info/user loc_sym/alias3 modbad/path spreadrc/dir1/1.0 -append/0.2 info/userexp loc_sym/alias4 modbad/paths spreadrc/dir2/1.0 -append/0.3 inforc/1.0 loc_sym/alias5 modbad/prepend-path spreadrc/dir3/1.0 -append/0.4 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/remove-path spreadrc/dir4/1.0 -append/0.5 inforc/foo(@) loc_sym/alias7 module/2.0 spreadrc/dir5/1.0 -append/1.0 load/00 loc_sym/alias8 module/bad spreadrc/dir6/1.0 -append/1.1 load/10 loc_sym/alias9 module/empty spreadrc/dir7/1.0 -append/1.3 load/11 loc_sym/alias10 module/err spreadrc/dir8/1.0 -append/1.4 load/12 loc_sym/alias11 module/lbad symlink/0.9 -append/1.5 load/13 loc_sym/exec1 module/lerr symlink/1(@) -append/1.6 load/14 loc_sym/exec2 module/lunk symlink/1.2(default:new) -append/1.7 load/15 loc_sym/exec3 module/meta symlink/bar(@) -append/2.0 load/16 loc_sym/getvers1 module/relpath symlink2/1.0 -append/2.1 load/17 loc_sym/getvers2 module/unk symlink2/2.0 -append/2.2 load/18 loc_sym/getvers3 modvar/modfile system/1.0 -append/2.3 load/19 loc_sym/getvers4 modvar/submodfile system/2.0 -append/2.4 load/20 loc_sym/getvers5 prepend/0.1 test/1.0 -append/4.0 load/21 loc_sym/getvers6 prepend/0.2 test/1.2 -append/4.1 load/22 loc_sym/getvers7 prepend/0.3 test/2.0 -append/5.0 load/23 loc_sym/getvers8 prepend/0.4 tr2_loc(trreg) -append/6.0 load/24 loc_sym/getvers9 prepend/0.5 tr2_loc/al1(tr2unstable:@) -averssort/1(@) load/25 loc_sym/getvers10 prepend/1.0 tr2_loc/al2(tr2bar:@) -averssort/1.2.4(@) load/26 loc_sym/versinf1 prepend/1.1 tr2_loc/al3(default:tr2exp:trreg:@) -averssort/1.10(@) load/27 loc_sym/versinf2 prepend/1.3 tr2_loc/al4(@) -bad/after(good) load/28 loc_sym/versinf3 prepend/1.4 tr2_loc/al5(default:trreg:@) -bad/before load/29 loc_sym/versinf4 prepend/1.5 tr_loc/al1(tr2unstable:trunstable:@) -bad2/body load/30 loc_sym/versinf5 prepend/1.6 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) -bad2/proc load/all(default) loc_sym/versinf6 prepend/1.7 tr_loc/al3(trexp:@) -break/1.0 loc_def/default loc_sym/versinf7 prepend/1.8 tr_loc/al4(@) -break/2.0 loc_def/truedef loc_sym/version1 prepend/1.9 tr_loc/al5(@) -break/3.0 loc_dv1/1.0 loc_sym/version2 prepend/2.0 trace/all_off -break/4.0 loc_dv1/2.0 loc_sym/version3 prepend/2.1 trace/all_on -break/5.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.2 uname/cache -break/6.0 loc_dv2/2.0 loc_sym/version5 prepend/2.3 uname/domain -chdir/1.0 loc_dv3/1.0 loc_sym/version6 prepend/2.4 uname/machine -chdir/2.0 loc_dv3/2.0 loc_sym/version7 prepend/3.0 uname/nodename -chdir/3.0 loc_dv4/1.0 loc_sym/version8 prepend/3.1 uname/release -chdir/4.0 loc_dv6/1.0 loc_sym/version9 prereq/full uname/sysname -coll/a loc_dv6/2.0/1.0 loc_sym/version10 prereq/fullpath uname/unk -coll/b loc_dv7/1.0 loc_sym/version11 prereq/module uname/version -coll/c loc_dv7/2.0(default) loc_sym/version12 prereq/orlist unsetenv/0.8 -coll/d loc_dv7/2.0/1.0 loc_sym/version13 prereq/relpath unsetenv/0.9 -conflict/full loc_dv7/3.0 loc_sym/version14 puts/1 unsetenv/1.0 -conflict/fullpath loc_dv8/1.0 loc_sym/version15 puts/2 use/1.0(default) -conflict/module loc_dv8/2.0 loc_sym/version16 puts/3 use/2.0 -conflict/relpath loc_dv9/1.0(default) loc_sym/version17 puts/4 use/2.1 -continue/1.0 loc_dv9/2.0 loc_sym/version18 puts/5 use/2.2 -continue/2.0 loc_dvv1/1.0(default) loc_sym/version19 puts/6 use/3.0 -continue/3.0 loc_dvv1/2.0 loc_sym/version20 puts/7 use/3.1 -continue/4.0 loc_fq/1.0 loc_sym/version21 puts/8 use/3.2 -continue/5.0 loc_rc1/1.0(foo) loc_sym/version22 recurs/modA use/4.0 -continue/6.0 loc_rc1/2.0 loc_sym/version23 recurs/modB use/4.1 -dirmodalias(@) loc_rc2/1.0(bar:blah:foo) loc_sym/version24 remove/0.3 user/adv -dirmodalias/1.0 loc_rc2/2.0 loc_sym/version25 remove/0.4 user/advanced -dirmodvirt loc_rc3/1.0(default) loc_sym/version26 remove/0.5 user/exp -dirmodvirt/1.0 loc_rc3/2.0(cur:stable) loc_tr(reg) remove/1.0 user/expert -empty/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.3 user/nov -eschars/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.4 user/novice -exit/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.5 user/undef -exit/2.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.6 verbose/msg -exit/3.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.7 verbose/off -exit/4.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/2.0 verbose/on -getenv/1.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.3 verbose/undef -help/2.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.4 versions/1.1 -info/command loc_rc6/1.2(default:new) loc_virt1/2.0 remove/3.0 versions/1.2 -info/commandexp loc_rc6/bar(@) loc_virt1/3.0 remove/3.1 versions/1.3 -info/isavail loc_rc7/0.9 loc_virt1/4.0 remove/4.0 verssort/1 -info/isloaded loc_rc7/1(@) loc_virt2/1.0 remove/4.1 verssort/1.2.1 -info/issaved loc_rc7/1.2 loc_virt2/2.0 remove/4.2 verssort/1.2.4 -info/isused loc_rc7/bar(@) log/badfac setenv/0.8 verssort/1.8-2015-12-01 -info/loaded loc_rc8/0.9(@) log/err_both_1 setenv/1.0 verssort/1.8-2016-02-01 -info/mode1 loc_rc8/1.0 log/err_both_2 source/0.9 verssort/1.10 -info/mode2 loc_rcv1/1(@) log/err_file source/1.0 whatis/lines -info/mode3 loc_rcv1/1.1 log/err_syslog source/1.1 whatis/multiple -info/mode4 loc_rcv1/1.2(default:new) modbad/append-path source/1.2 whatis/none -info/mode5 loc_rcv1/2.0 modbad/autoinit spread/1.0 whatis/single -info/mode6 loc_rcv1/bar(@) modbad/foo spread/2.0 whatis/string -info/name loc_rcv2/1.2 modbad/help spread/3.0 x-resource/1 -info/others loc_rcv2/1.5 modbad/info-loaded spread/4.0 -info/shells loc_rcv2/2.0 modbad/is-avail spread/5.0 -info/shellsexp loc_sym/1.0 modbad/is-loaded spread/6.0 " +alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/6.0 +alias/2.0 info/type loc_sym/alias2 modbad/is-saved spread/7.0 +append/0.1 info/user loc_sym/alias3 modbad/is-used spread/8.0 +append/0.2 info/userexp loc_sym/alias4 modbad/path spreadrc/dir1/1.0 +append/0.3 inforc/1.0 loc_sym/alias5 modbad/paths spreadrc/dir2/1.0 +append/0.4 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/prepend-path spreadrc/dir3/1.0 +append/0.5 inforc/foo(@) loc_sym/alias7 modbad/remove-path spreadrc/dir4/1.0 +append/1.0 load/00 loc_sym/alias8 module/2.0 spreadrc/dir5/1.0 +append/1.1 load/10 loc_sym/alias9 module/bad spreadrc/dir6/1.0 +append/1.3 load/11 loc_sym/alias10 module/empty spreadrc/dir7/1.0 +append/1.4 load/12 loc_sym/alias11 module/err spreadrc/dir8/1.0 +append/1.5 load/13 loc_sym/exec1 module/lbad symlink/0.9 +append/1.6 load/14 loc_sym/exec2 module/lerr symlink/1(@) +append/1.7 load/15 loc_sym/exec3 module/lunk symlink/1.2(default:new) +append/2.0 load/16 loc_sym/getvers1 module/meta symlink/bar(@) +append/2.1 load/17 loc_sym/getvers2 module/relpath symlink2/1.0 +append/2.2 load/18 loc_sym/getvers3 module/unk symlink2/2.0 +append/2.3 load/19 loc_sym/getvers4 modvar/modfile system/1.0 +append/2.4 load/20 loc_sym/getvers5 modvar/submodfile system/2.0 +append/4.0 load/21 loc_sym/getvers6 prepend/0.1 test/1.0 +append/4.1 load/22 loc_sym/getvers7 prepend/0.2 test/1.2 +append/5.0 load/23 loc_sym/getvers8 prepend/0.3 test/2.0 +append/6.0 load/24 loc_sym/getvers9 prepend/0.4 tr2_loc(trreg) +averssort/1(@) load/25 loc_sym/getvers10 prepend/0.5 tr2_loc/al1(tr2unstable:@) +averssort/1.2.4(@) load/26 loc_sym/versinf1 prepend/1.0 tr2_loc/al2(tr2bar:@) +averssort/1.10(@) load/27 loc_sym/versinf2 prepend/1.1 tr2_loc/al3(default:tr2exp:trreg:@) +bad/after(good) load/28 loc_sym/versinf3 prepend/1.3 tr2_loc/al4(@) +bad/before load/29 loc_sym/versinf4 prepend/1.4 tr2_loc/al5(default:trreg:@) +bad2/body load/30 loc_sym/versinf5 prepend/1.5 tr_loc/al1(tr2unstable:trunstable:@) +bad2/proc load/all(default) loc_sym/versinf6 prepend/1.6 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) +break/1.0 loc_def/default loc_sym/versinf7 prepend/1.7 tr_loc/al3(trexp:@) +break/2.0 loc_def/truedef loc_sym/version1 prepend/1.8 tr_loc/al4(@) +break/3.0 loc_dv1/1.0 loc_sym/version2 prepend/1.9 tr_loc/al5(@) +break/4.0 loc_dv1/2.0 loc_sym/version3 prepend/2.0 trace/all_off +break/5.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.1 trace/all_on +break/6.0 loc_dv2/2.0 loc_sym/version5 prepend/2.2 uname/cache +chdir/1.0 loc_dv3/1.0 loc_sym/version6 prepend/2.3 uname/domain +chdir/2.0 loc_dv3/2.0 loc_sym/version7 prepend/2.4 uname/machine +chdir/3.0 loc_dv4/1.0 loc_sym/version8 prepend/3.0 uname/nodename +chdir/4.0 loc_dv6/1.0 loc_sym/version9 prepend/3.1 uname/release +coll/a loc_dv6/2.0/1.0 loc_sym/version10 prereq/full uname/sysname +coll/b loc_dv7/1.0 loc_sym/version11 prereq/fullpath uname/unk +coll/c loc_dv7/2.0(default) loc_sym/version12 prereq/module uname/version +coll/d loc_dv7/2.0/1.0 loc_sym/version13 prereq/orlist unsetenv/0.8 +conflict/full loc_dv7/3.0 loc_sym/version14 prereq/relpath unsetenv/0.9 +conflict/fullpath loc_dv8/1.0 loc_sym/version15 puts/1 unsetenv/1.0 +conflict/module loc_dv8/2.0 loc_sym/version16 puts/2 use/1.0(default) +conflict/relpath loc_dv9/1.0(default) loc_sym/version17 puts/3 use/2.0 +continue/1.0 loc_dv9/2.0 loc_sym/version18 puts/4 use/2.1 +continue/2.0 loc_dvv1/1.0(default) loc_sym/version19 puts/5 use/2.2 +continue/3.0 loc_dvv1/2.0 loc_sym/version20 puts/6 use/3.0 +continue/4.0 loc_fq/1.0 loc_sym/version21 puts/7 use/3.1 +continue/5.0 loc_rc1/1.0(foo) loc_sym/version22 puts/8 use/3.2 +continue/6.0 loc_rc1/2.0 loc_sym/version23 recurs/modA use/4.0 +dirmodalias(@) loc_rc2/1.0(bar:blah:foo) loc_sym/version24 recurs/modB use/4.1 +dirmodalias/1.0 loc_rc2/2.0 loc_sym/version25 remove/0.3 user/adv +dirmodvirt loc_rc3/1.0(default) loc_sym/version26 remove/0.4 user/advanced +dirmodvirt/1.0 loc_rc3/2.0(cur:stable) loc_tr(reg) remove/0.5 user/exp +empty/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.0 user/expert +eschars/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.3 user/nov +exit/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.4 user/novice +exit/2.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.5 user/undef +exit/3.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.6 verbose/msg +exit/4.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/1.7 verbose/off +getenv/1.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.0 verbose/on +help/2.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.3 verbose/undef +info/command loc_rc6/1.2(default:new) loc_virt1/2.0 remove/2.4 versions/1.1 +info/commandexp loc_rc6/bar(@) loc_virt1/3.0 remove/3.0 versions/1.2 +info/isavail loc_rc7/0.9 loc_virt1/4.0 remove/3.1 versions/1.3 +info/isloaded loc_rc7/1(@) loc_virt2/1.0 remove/4.0 verssort/1 +info/issaved loc_rc7/1.2 loc_virt2/2.0 remove/4.1 verssort/1.2.1 +info/isused loc_rc7/bar(@) log/badfac remove/4.2 verssort/1.2.4 +info/loaded loc_rc8/0.9(@) log/err_both_1 setenv/0.8 verssort/1.8-2015-12-01 +info/mode1 loc_rc8/1.0 log/err_both_2 setenv/1.0 verssort/1.8-2016-02-01 +info/mode2 loc_rcv1/1(@) log/err_file source/0.9 verssort/1.10 +info/mode3 loc_rcv1/1.1 log/err_syslog source/1.0 whatis/lines +info/mode4 loc_rcv1/1.2(default:new) modbad/append-path source/1.1 whatis/multiple +info/mode5 loc_rcv1/2.0 modbad/autoinit source/1.2 whatis/none +info/mode6 loc_rcv1/bar(@) modbad/empty spread/1.0 whatis/single +info/name loc_rcv2/1.2 modbad/foo spread/2.0 whatis/string +info/others loc_rcv2/1.5 modbad/help spread/3.0 x-resource/1 +info/shells loc_rcv2/2.0 modbad/info-loaded spread/4.0 +info/shellsexp loc_sym/1.0 modbad/is-avail spread/5.0 " set ts_sh_small "- $modpath.deep - dir2/1.0(d1) From 00081a6db38b0f900326da8ab226f41f923a9f06 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 6 Apr 2018 15:48:47 +0200 Subject: [PATCH 02/28] Make setenv alter ::env() on help/test/whatis modes Set the variable passed to 'setenv' procedure in ::env() array to make it available for later use during the modulefile evaluation. Add 50-cmds/029-setenv-env tests to check this ::env() array change over all evaluation mode. Adapt 50-cmds/350-allin to check this change against 'whatis' mode. Fixes #160 --- modulecmd.tcl.in | 16 +- testsuite/modulefiles/setenv/0.6 | 29 ++++ testsuite/modules.50-cmds/029-setenv-env.exp | 172 +++++++++++++++++++ testsuite/modules.90-avail/070-full.exp | 166 +++++++++--------- 4 files changed, 295 insertions(+), 88 deletions(-) create mode 100644 testsuite/modulefiles/setenv/0.6 create mode 100644 testsuite/modules.50-cmds/029-setenv-env.exp diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 8da9c63fe..3e9fbe8b0 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -1630,13 +1630,22 @@ proc setenv {var val} { reportDebug "setenv: ($var,$val) mode = $mode" - if {$mode eq "load"} { + # Set the variable for later use during the modulefile evaluation + # for all mode except unload + if {$mode ne "unload"} { set ::env($var) $val - set ::g_stateEnvVars($var) "new" # clean any previously defined reference counter array set sharevar [getModshareVarName $var] if {[info exists ::env($sharevar)]} { unset-env $sharevar + set sharevarunset 1 + } + } + + # propagate variable setup to shell environment on load mode + if {$mode eq "load"} { + set ::g_stateEnvVars($var) "new" + if {[info exists sharevarunset]} { set ::g_stateEnvVars($sharevar) "del" } }\ @@ -1647,9 +1656,6 @@ proc setenv {var val} { set ::g_stateEnvVars($var) "del" }\ elseif {$mode eq "display" && !$::g_inhibit_dispreport} { - # Let display set the variable for later use in the display - # but don't commit it to the env - set ::env($var) $val report "setenv\t\t$var\t$val" } return {} diff --git a/testsuite/modulefiles/setenv/0.6 b/testsuite/modulefiles/setenv/0.6 new file mode 100644 index 000000000..d7aacf759 --- /dev/null +++ b/testsuite/modulefiles/setenv/0.6 @@ -0,0 +1,29 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: setenv/%M% +# Revision: %I% +# First Edition: 2018/04/06 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: +# Sub-Command: setenv +# +# Invocation: load, unload, display, help, test +# Result: %R{ +# }R% +# Comment: %C{ +# Check the effect of 'setenv' command on $env() array variable +# through the different modulefile evaluation mode +# }C% +# +############################################################################## + +setenv TS1 yes +setenv TS2 $env(TS1) diff --git a/testsuite/modules.50-cmds/029-setenv-env.exp b/testsuite/modules.50-cmds/029-setenv-env.exp new file mode 100644 index 000000000..6a5f18156 --- /dev/null +++ b/testsuite/modules.50-cmds/029-setenv-env.exp @@ -0,0 +1,172 @@ +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: modules.50-cmds/%M% +# Revision: %I% +# First Edition: 2018/04/06 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite testsequence +# Command: load, unload, display, help, test +# Modulefiles: setenv/0.6 +# Sub-Command: +# +# Comment: %C{ +# Check the effect of 'setenv' command on $env() array variable +# through the different modulefile evaluation mode +# }C% +# +############################################################################## + +set module "setenv/0.6" +set modulefile "$modpath/$module" +set modulefilere "$modpathre/$module" + +# +# test load mode +# + +set ans [list] +lappend ans [list set TS1 yes] +lappend ans [list set TS2 yes] +lappend ans [list setpath LOADEDMODULES $module] +lappend ans [list setpath _LMFILES_ $modulefile] +testouterr_cmd "sh" "load $module" $ans "" + +# test with value set to variable prior to load +set env(TS1) "no" +testouterr_cmd "sh" "load $module" $ans "" + + +# +# test unload mode +# + +# test with module loaded +set env(TS1) "yes" +set env(TS2) "yes" +set env(LOADEDMODULES) $module +set env(_LMFILES_) $modulefile + +set ans [list] +lappend ans [list unset TS1] +lappend ans [list unset TS2] +lappend ans [list unsetpath LOADEDMODULES] +lappend ans [list unsetpath _LMFILES_] +testouterr_cmd "sh" "unload $module" $ans "" + +# test with module loaded but vanished env vars +unset env(TS1) +unset env(TS2) + +# raise an error +set tserr "$moderr_msgs: can't read \"env(TS1)\": no such variable + In '$modulefile' +$err_contact" + +testouterr_cmd "sh" "unload $module" "ERR" $tserr + + +# restore environment +unset env(LOADEDMODULES) +unset env(_LMFILES_) + + +# +# test display mode +# + +set tserr "$modlin +$modulefilere: + +setenv\t\tTS1\tyes +setenv\t\tTS2\tyes +$modlin" + +# test without module loaded +testouterr_cmd_re "sh" "display $module" "" $tserr + +# test with module loaded +set env(TS1) "yes" +set env(TS2) "yes" +set env(LOADEDMODULES) $module +set env(_LMFILES_) $modulefile + +testouterr_cmd_re "sh" "display $module" "" $tserr + +# restore environment +unset env(TS1) +unset env(TS2) +unset env(LOADEDMODULES) +unset env(_LMFILES_) + + +# +# test help mode +# + +set tserr "$modlin +Module Specific Help for $modulefilere: + +$warn_msgs: Unable to find ModulesHelp in $modulefilere. +$modlin" + +# test without module loaded +testouterr_cmd_re "sh" "help $module" "" $tserr + +# test with module loaded +set env(TS1) "yes" +set env(TS2) "yes" +set env(LOADEDMODULES) $module +set env(_LMFILES_) $modulefile + +testouterr_cmd_re "sh" "help $module" "" $tserr + +# restore environment +unset env(TS1) +unset env(TS2) +unset env(LOADEDMODULES) +unset env(_LMFILES_) + + +# +# test test mode +# + +set tserr "$modlin +Module Specific Test for $modulefilere: + +$warn_msgs: Unable to find ModulesTest in $modulefilere. +$modlin" + +# test without module loaded +testouterr_cmd_re "sh" "test $module" "" $tserr + +# test with module previously loaded +set env(TS1) "yes" +set env(TS2) "yes" +set env(LOADEDMODULES) $module +set env(_LMFILES_) $modulefile + +testouterr_cmd_re "sh" "test $module" "" $tserr + +# restore environment +unset env(TS1) +unset env(TS2) +unset env(LOADEDMODULES) +unset env(_LMFILES_) + + +# +# Cleanup +# + +unset tserr +unset ans + +unset modulefilere +unset modulefile +unset module diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 883ed69a7..9ed543c5f 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -41,89 +41,89 @@ set len [string length $modpath] set lrep [expr {($test_cols - $len - 2)/2}] set rrep [expr {$test_cols - $len - 2 - $lrep}] set ts_sh "[string repeat {-} $lrep] $modpath [string repeat {-} $rrep] -alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/6.0 -alias/2.0 info/type loc_sym/alias2 modbad/is-saved spread/7.0 -append/0.1 info/user loc_sym/alias3 modbad/is-used spread/8.0 -append/0.2 info/userexp loc_sym/alias4 modbad/path spreadrc/dir1/1.0 -append/0.3 inforc/1.0 loc_sym/alias5 modbad/paths spreadrc/dir2/1.0 -append/0.4 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/prepend-path spreadrc/dir3/1.0 -append/0.5 inforc/foo(@) loc_sym/alias7 modbad/remove-path spreadrc/dir4/1.0 -append/1.0 load/00 loc_sym/alias8 module/2.0 spreadrc/dir5/1.0 -append/1.1 load/10 loc_sym/alias9 module/bad spreadrc/dir6/1.0 -append/1.3 load/11 loc_sym/alias10 module/empty spreadrc/dir7/1.0 -append/1.4 load/12 loc_sym/alias11 module/err spreadrc/dir8/1.0 -append/1.5 load/13 loc_sym/exec1 module/lbad symlink/0.9 -append/1.6 load/14 loc_sym/exec2 module/lerr symlink/1(@) -append/1.7 load/15 loc_sym/exec3 module/lunk symlink/1.2(default:new) -append/2.0 load/16 loc_sym/getvers1 module/meta symlink/bar(@) -append/2.1 load/17 loc_sym/getvers2 module/relpath symlink2/1.0 -append/2.2 load/18 loc_sym/getvers3 module/unk symlink2/2.0 -append/2.3 load/19 loc_sym/getvers4 modvar/modfile system/1.0 -append/2.4 load/20 loc_sym/getvers5 modvar/submodfile system/2.0 -append/4.0 load/21 loc_sym/getvers6 prepend/0.1 test/1.0 -append/4.1 load/22 loc_sym/getvers7 prepend/0.2 test/1.2 -append/5.0 load/23 loc_sym/getvers8 prepend/0.3 test/2.0 -append/6.0 load/24 loc_sym/getvers9 prepend/0.4 tr2_loc(trreg) -averssort/1(@) load/25 loc_sym/getvers10 prepend/0.5 tr2_loc/al1(tr2unstable:@) -averssort/1.2.4(@) load/26 loc_sym/versinf1 prepend/1.0 tr2_loc/al2(tr2bar:@) -averssort/1.10(@) load/27 loc_sym/versinf2 prepend/1.1 tr2_loc/al3(default:tr2exp:trreg:@) -bad/after(good) load/28 loc_sym/versinf3 prepend/1.3 tr2_loc/al4(@) -bad/before load/29 loc_sym/versinf4 prepend/1.4 tr2_loc/al5(default:trreg:@) -bad2/body load/30 loc_sym/versinf5 prepend/1.5 tr_loc/al1(tr2unstable:trunstable:@) -bad2/proc load/all(default) loc_sym/versinf6 prepend/1.6 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) -break/1.0 loc_def/default loc_sym/versinf7 prepend/1.7 tr_loc/al3(trexp:@) -break/2.0 loc_def/truedef loc_sym/version1 prepend/1.8 tr_loc/al4(@) -break/3.0 loc_dv1/1.0 loc_sym/version2 prepend/1.9 tr_loc/al5(@) -break/4.0 loc_dv1/2.0 loc_sym/version3 prepend/2.0 trace/all_off -break/5.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.1 trace/all_on -break/6.0 loc_dv2/2.0 loc_sym/version5 prepend/2.2 uname/cache -chdir/1.0 loc_dv3/1.0 loc_sym/version6 prepend/2.3 uname/domain -chdir/2.0 loc_dv3/2.0 loc_sym/version7 prepend/2.4 uname/machine -chdir/3.0 loc_dv4/1.0 loc_sym/version8 prepend/3.0 uname/nodename -chdir/4.0 loc_dv6/1.0 loc_sym/version9 prepend/3.1 uname/release -coll/a loc_dv6/2.0/1.0 loc_sym/version10 prereq/full uname/sysname -coll/b loc_dv7/1.0 loc_sym/version11 prereq/fullpath uname/unk -coll/c loc_dv7/2.0(default) loc_sym/version12 prereq/module uname/version -coll/d loc_dv7/2.0/1.0 loc_sym/version13 prereq/orlist unsetenv/0.8 -conflict/full loc_dv7/3.0 loc_sym/version14 prereq/relpath unsetenv/0.9 -conflict/fullpath loc_dv8/1.0 loc_sym/version15 puts/1 unsetenv/1.0 -conflict/module loc_dv8/2.0 loc_sym/version16 puts/2 use/1.0(default) -conflict/relpath loc_dv9/1.0(default) loc_sym/version17 puts/3 use/2.0 -continue/1.0 loc_dv9/2.0 loc_sym/version18 puts/4 use/2.1 -continue/2.0 loc_dvv1/1.0(default) loc_sym/version19 puts/5 use/2.2 -continue/3.0 loc_dvv1/2.0 loc_sym/version20 puts/6 use/3.0 -continue/4.0 loc_fq/1.0 loc_sym/version21 puts/7 use/3.1 -continue/5.0 loc_rc1/1.0(foo) loc_sym/version22 puts/8 use/3.2 -continue/6.0 loc_rc1/2.0 loc_sym/version23 recurs/modA use/4.0 -dirmodalias(@) loc_rc2/1.0(bar:blah:foo) loc_sym/version24 recurs/modB use/4.1 -dirmodalias/1.0 loc_rc2/2.0 loc_sym/version25 remove/0.3 user/adv -dirmodvirt loc_rc3/1.0(default) loc_sym/version26 remove/0.4 user/advanced -dirmodvirt/1.0 loc_rc3/2.0(cur:stable) loc_tr(reg) remove/0.5 user/exp -empty/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.0 user/expert -eschars/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.3 user/nov -exit/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.4 user/novice -exit/2.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.5 user/undef -exit/3.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.6 verbose/msg -exit/4.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/1.7 verbose/off -getenv/1.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.0 verbose/on -help/2.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.3 verbose/undef -info/command loc_rc6/1.2(default:new) loc_virt1/2.0 remove/2.4 versions/1.1 -info/commandexp loc_rc6/bar(@) loc_virt1/3.0 remove/3.0 versions/1.2 -info/isavail loc_rc7/0.9 loc_virt1/4.0 remove/3.1 versions/1.3 -info/isloaded loc_rc7/1(@) loc_virt2/1.0 remove/4.0 verssort/1 -info/issaved loc_rc7/1.2 loc_virt2/2.0 remove/4.1 verssort/1.2.1 -info/isused loc_rc7/bar(@) log/badfac remove/4.2 verssort/1.2.4 -info/loaded loc_rc8/0.9(@) log/err_both_1 setenv/0.8 verssort/1.8-2015-12-01 -info/mode1 loc_rc8/1.0 log/err_both_2 setenv/1.0 verssort/1.8-2016-02-01 -info/mode2 loc_rcv1/1(@) log/err_file source/0.9 verssort/1.10 -info/mode3 loc_rcv1/1.1 log/err_syslog source/1.0 whatis/lines -info/mode4 loc_rcv1/1.2(default:new) modbad/append-path source/1.1 whatis/multiple -info/mode5 loc_rcv1/2.0 modbad/autoinit source/1.2 whatis/none -info/mode6 loc_rcv1/bar(@) modbad/empty spread/1.0 whatis/single -info/name loc_rcv2/1.2 modbad/foo spread/2.0 whatis/string -info/others loc_rcv2/1.5 modbad/help spread/3.0 x-resource/1 -info/shells loc_rcv2/2.0 modbad/info-loaded spread/4.0 -info/shellsexp loc_sym/1.0 modbad/is-avail spread/5.0 " +alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/5.0 +alias/2.0 info/type loc_sym/alias2 modbad/is-saved spread/6.0 +append/0.1 info/user loc_sym/alias3 modbad/is-used spread/7.0 +append/0.2 info/userexp loc_sym/alias4 modbad/path spread/8.0 +append/0.3 inforc/1.0 loc_sym/alias5 modbad/paths spreadrc/dir1/1.0 +append/0.4 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/prepend-path spreadrc/dir2/1.0 +append/0.5 inforc/foo(@) loc_sym/alias7 modbad/remove-path spreadrc/dir3/1.0 +append/1.0 load/00 loc_sym/alias8 module/2.0 spreadrc/dir4/1.0 +append/1.1 load/10 loc_sym/alias9 module/bad spreadrc/dir5/1.0 +append/1.3 load/11 loc_sym/alias10 module/empty spreadrc/dir6/1.0 +append/1.4 load/12 loc_sym/alias11 module/err spreadrc/dir7/1.0 +append/1.5 load/13 loc_sym/exec1 module/lbad spreadrc/dir8/1.0 +append/1.6 load/14 loc_sym/exec2 module/lerr symlink/0.9 +append/1.7 load/15 loc_sym/exec3 module/lunk symlink/1(@) +append/2.0 load/16 loc_sym/getvers1 module/meta symlink/1.2(default:new) +append/2.1 load/17 loc_sym/getvers2 module/relpath symlink/bar(@) +append/2.2 load/18 loc_sym/getvers3 module/unk symlink2/1.0 +append/2.3 load/19 loc_sym/getvers4 modvar/modfile symlink2/2.0 +append/2.4 load/20 loc_sym/getvers5 modvar/submodfile system/1.0 +append/4.0 load/21 loc_sym/getvers6 prepend/0.1 system/2.0 +append/4.1 load/22 loc_sym/getvers7 prepend/0.2 test/1.0 +append/5.0 load/23 loc_sym/getvers8 prepend/0.3 test/1.2 +append/6.0 load/24 loc_sym/getvers9 prepend/0.4 test/2.0 +averssort/1(@) load/25 loc_sym/getvers10 prepend/0.5 tr2_loc(trreg) +averssort/1.2.4(@) load/26 loc_sym/versinf1 prepend/1.0 tr2_loc/al1(tr2unstable:@) +averssort/1.10(@) load/27 loc_sym/versinf2 prepend/1.1 tr2_loc/al2(tr2bar:@) +bad/after(good) load/28 loc_sym/versinf3 prepend/1.3 tr2_loc/al3(default:tr2exp:trreg:@) +bad/before load/29 loc_sym/versinf4 prepend/1.4 tr2_loc/al4(@) +bad2/body load/30 loc_sym/versinf5 prepend/1.5 tr2_loc/al5(default:trreg:@) +bad2/proc load/all(default) loc_sym/versinf6 prepend/1.6 tr_loc/al1(tr2unstable:trunstable:@) +break/1.0 loc_def/default loc_sym/versinf7 prepend/1.7 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) +break/2.0 loc_def/truedef loc_sym/version1 prepend/1.8 tr_loc/al3(trexp:@) +break/3.0 loc_dv1/1.0 loc_sym/version2 prepend/1.9 tr_loc/al4(@) +break/4.0 loc_dv1/2.0 loc_sym/version3 prepend/2.0 tr_loc/al5(@) +break/5.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.1 trace/all_off +break/6.0 loc_dv2/2.0 loc_sym/version5 prepend/2.2 trace/all_on +chdir/1.0 loc_dv3/1.0 loc_sym/version6 prepend/2.3 uname/cache +chdir/2.0 loc_dv3/2.0 loc_sym/version7 prepend/2.4 uname/domain +chdir/3.0 loc_dv4/1.0 loc_sym/version8 prepend/3.0 uname/machine +chdir/4.0 loc_dv6/1.0 loc_sym/version9 prepend/3.1 uname/nodename +coll/a loc_dv6/2.0/1.0 loc_sym/version10 prereq/full uname/release +coll/b loc_dv7/1.0 loc_sym/version11 prereq/fullpath uname/sysname +coll/c loc_dv7/2.0(default) loc_sym/version12 prereq/module uname/unk +coll/d loc_dv7/2.0/1.0 loc_sym/version13 prereq/orlist uname/version +conflict/full loc_dv7/3.0 loc_sym/version14 prereq/relpath unsetenv/0.8 +conflict/fullpath loc_dv8/1.0 loc_sym/version15 puts/1 unsetenv/0.9 +conflict/module loc_dv8/2.0 loc_sym/version16 puts/2 unsetenv/1.0 +conflict/relpath loc_dv9/1.0(default) loc_sym/version17 puts/3 use/1.0(default) +continue/1.0 loc_dv9/2.0 loc_sym/version18 puts/4 use/2.0 +continue/2.0 loc_dvv1/1.0(default) loc_sym/version19 puts/5 use/2.1 +continue/3.0 loc_dvv1/2.0 loc_sym/version20 puts/6 use/2.2 +continue/4.0 loc_fq/1.0 loc_sym/version21 puts/7 use/3.0 +continue/5.0 loc_rc1/1.0(foo) loc_sym/version22 puts/8 use/3.1 +continue/6.0 loc_rc1/2.0 loc_sym/version23 recurs/modA use/3.2 +dirmodalias(@) loc_rc2/1.0(bar:blah:foo) loc_sym/version24 recurs/modB use/4.0 +dirmodalias/1.0 loc_rc2/2.0 loc_sym/version25 remove/0.3 use/4.1 +dirmodvirt loc_rc3/1.0(default) loc_sym/version26 remove/0.4 user/adv +dirmodvirt/1.0 loc_rc3/2.0(cur:stable) loc_tr(reg) remove/0.5 user/advanced +empty/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.0 user/exp +eschars/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.3 user/expert +exit/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.4 user/nov +exit/2.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.5 user/novice +exit/3.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.6 user/undef +exit/4.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/1.7 verbose/msg +getenv/1.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.0 verbose/off +help/2.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.3 verbose/on +info/command loc_rc6/1.2(default:new) loc_virt1/2.0 remove/2.4 verbose/undef +info/commandexp loc_rc6/bar(@) loc_virt1/3.0 remove/3.0 versions/1.1 +info/isavail loc_rc7/0.9 loc_virt1/4.0 remove/3.1 versions/1.2 +info/isloaded loc_rc7/1(@) loc_virt2/1.0 remove/4.0 versions/1.3 +info/issaved loc_rc7/1.2 loc_virt2/2.0 remove/4.1 verssort/1 +info/isused loc_rc7/bar(@) log/badfac remove/4.2 verssort/1.2.1 +info/loaded loc_rc8/0.9(@) log/err_both_1 setenv/0.6 verssort/1.2.4 +info/mode1 loc_rc8/1.0 log/err_both_2 setenv/0.8 verssort/1.8-2015-12-01 +info/mode2 loc_rcv1/1(@) log/err_file setenv/1.0 verssort/1.8-2016-02-01 +info/mode3 loc_rcv1/1.1 log/err_syslog source/0.9 verssort/1.10 +info/mode4 loc_rcv1/1.2(default:new) modbad/append-path source/1.0 whatis/lines +info/mode5 loc_rcv1/2.0 modbad/autoinit source/1.1 whatis/multiple +info/mode6 loc_rcv1/bar(@) modbad/empty source/1.2 whatis/none +info/name loc_rcv2/1.2 modbad/foo spread/1.0 whatis/single +info/others loc_rcv2/1.5 modbad/help spread/2.0 whatis/string +info/shells loc_rcv2/2.0 modbad/info-loaded spread/3.0 x-resource/1 +info/shellsexp loc_sym/1.0 modbad/is-avail spread/4.0 " set ts_sh_small "- $modpath.deep - dir2/1.0(d1) From 1814d27af7634d50f9034424605f58f1a281cfce Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Tue, 17 Apr 2018 10:17:32 +0200 Subject: [PATCH 03/28] doc: desc. MANPATH special treatment on compat version Describe the difference behavior between Modules 4+ and compatibility version regarding how append-path/prepend-path commands handle the MANPATH environment variable when unset. Helps clarify [1]. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1564899 --- doc/source/diff_v3_v4.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/diff_v3_v4.rst b/doc/source/diff_v3_v4.rst index ddc7ebdc4..5aa40e1b6 100644 --- a/doc/source/diff_v3_v4.rst +++ b/doc/source/diff_v3_v4.rst @@ -153,6 +153,8 @@ Modules Specific Tcl Commands Modules 4 supports adding or removing empty path element to a path-like variable, whereas compatibility version looses track of this path element when the path-like variable is modified afterward. Empty path element enables to set a leading colon character *:*, which has a specific meaning on some regular environment variable like **MANPATH** or **LD_LIBRARY_PATH**. + When adding a path element to the **MANPATH** environment variable, Modules 4 is treating this variable like any other whereas a special treatment was applied on compatibility version: a default MANPATH value, set at configure time, was appended in case **MANPATH** variable was unset. + **remove-path** Modules 4 provides path element counting feature which increases a reference counter each time a given path entry is added to a given environment variable. As consequence a path entry element is removed from a path-like variable only if the related element counter is equal to 1. If this counter is greater than 1, path element is kept in variable and reference counter is decreased by 1. From b3036418dc4f4beea0108444f254c6d3be3e65e6 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sat, 19 May 2018 09:32:54 +0200 Subject: [PATCH 04/28] init: init/export _module_raw if stderr attached to term To get coherent with the test made by modulecmd.tcl to determine if autoinit sub-command has to produce code for the '_module_raw' shell function, export this function (or initialize it on compat mode) if stderr is attached to a terminal. Was previously testing stdout, whereas modulecmd.tcl is checking stderr, which led to inconsistencies as described in [1]. Fixes #169 [1] https://bugzilla.redhat.com/show_bug.cgi?id=1575479 --- init/bash.in | 4 ++-- init/ksh.in | 2 +- init/sh.in | 4 ++-- init/zsh.in | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/init/bash.in b/init/bash.in index ce9822b43..1a111e41d 100644 --- a/init/bash.in +++ b/init/bash.in @@ -48,7 +48,7 @@ unset _mlre _mlv _mlrv @compatversion@# redefine module command if compat version has been activated @compatversion@if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then @compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat; export MODULES_CMD -@compatversion@ if [ -t 1 ]; then +@compatversion@ if [ -t 2 ]; then @compatversion@ _moduleraw() { eval `@libexecdir@/modulecmd-compat bash $*`; } @compatversion@ else @compatversion@ module() { eval `@libexecdir@/modulecmd-compat bash $*`; } @@ -56,7 +56,7 @@ unset _mlre _mlv _mlrv @compatversion@fi @compatversion@ # export functions to get them defined in sub-shells -if [ -t 1 ]; then +if [ -t 2 ]; then export -f _moduleraw fi export -f module diff --git a/init/ksh.in b/init/ksh.in index 834b8224d..f0db26533 100644 --- a/init/ksh.in +++ b/init/ksh.in @@ -48,7 +48,7 @@ unset _mlre _mlv _mlrv @compatversion@# redefine module command if compat version has been activated @compatversion@if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then @compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat; export MODULES_CMD -@compatversion@ if [ -t 1 ]; then +@compatversion@ if [ -t 2 ]; then @compatversion@ _moduleraw() { eval `@libexecdir@/modulecmd-compat ksh $*`; } @compatversion@ else @compatversion@ module() { eval `@libexecdir@/modulecmd-compat ksh $*`; } diff --git a/init/sh.in b/init/sh.in index 197b865e3..2fa271c59 100644 --- a/init/sh.in +++ b/init/sh.in @@ -48,7 +48,7 @@ unset _mlre _mlv _mlrv @compatversion@# redefine module command if compat version has been activated @compatversion@if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then @compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat; export MODULES_CMD -@compatversion@ if [ -t 1 ]; then +@compatversion@ if [ -t 2 ]; then @compatversion@ _moduleraw() { eval `@libexecdir@/modulecmd-compat sh $*`; } @compatversion@ else @compatversion@ module() { eval `@libexecdir@/modulecmd-compat sh $*`; } @@ -57,7 +57,7 @@ unset _mlre _mlv _mlrv @compatversion@ # if sh is bash, export functions to get them defined in sub-shells if [ "${BASH:-}" != '' ]; then - if [ -t 1 ]; then + if [ -t 2 ]; then export -f _moduleraw fi export -f module diff --git a/init/zsh.in b/init/zsh.in index b2c10ef6a..54244bba7 100644 --- a/init/zsh.in +++ b/init/zsh.in @@ -48,7 +48,7 @@ unset _mlre _mlv _mlrv @compatversion@# redefine module command if compat version has been activated @compatversion@if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then @compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat; export MODULES_CMD -@compatversion@ if [ -t 1 ]; then +@compatversion@ if [ -t 2 ]; then @compatversion@ _moduleraw() { eval `@libexecdir@/modulecmd-compat zsh $*`; } @compatversion@ else @compatversion@ module() { eval `@libexecdir@/modulecmd-compat zsh $*`; } From 616c4a543dab895d0e4e54989f49a1ef6677a4b3 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sat, 19 May 2018 21:34:41 +0200 Subject: [PATCH 05/28] Quote csh generated code to pass it to eval Brace modulecmd.tcl call in module csh alias with quotes to pass quoted content to the shell evaluation. Use :q modifier on !* to escape quotes passed as arguments to the module command --- modulecmd.tcl.in | 2 +- testsuite/modules.70-maint/120-autoinit.exp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 3e9fbe8b0..ff72840a6 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -3454,7 +3454,7 @@ proc renderAutoinit {} { set post_hi {set histchars = $_histchars; unset _histchars;} set pre_pr {set _prompt="$prompt"; set prompt="";} set post_pr {set prompt="$_prompt"; unset _prompt;} - set eval_cmd "eval `$tclshbin $::argv0 $::g_shell \\!*`;" + set eval_cmd "eval \"`$tclshbin $::argv0 $::g_shell \\!*:q`\";" set pre_ex {set _exit="$status";} set post_ex {test 0 = $_exit} diff --git a/testsuite/modules.70-maint/120-autoinit.exp b/testsuite/modules.70-maint/120-autoinit.exp index 1604f22b7..508e98b18 100644 --- a/testsuite/modules.70-maint/120-autoinit.exp +++ b/testsuite/modules.70-maint/120-autoinit.exp @@ -159,14 +159,14 @@ set func_sh "$func_name\\\(\\\) {\n$func_silentdbg\n$func_quar_sh\n$func_modcmd_ set func_bash "$func_name\\\(\\\) {\n$func_silentdbg\n$func_quar_sh\n$func_modcmd_bash\n\\s*_mlstatus=\\\$\\\?;\n$func_clean_ifs\n};$add_func_sh" set func_ksh "$func_name\\\(\\\) {\n$func_silentdbg\n$func_quar_sh\n$func_modcmd_ksh\n\\s*_mlstatus=\\\$\\\?;\n$func_clean_ifs\n};$add_func_sh" set func_zsh "$func_name\\\(\\\) {\n$func_silentdbg\n$func_quar_zsh\n$func_modcmd_zsh\n\\s*_mlstatus=\\\$\\\?;\n$func_clean_ifs\n};$add_func_sh" -set func_csh "if \\\( \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval `$install_tclsh $modulecmd_pathre csh \\\\!\\*`; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; -if \\\( \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; eval `$install_tclsh $modulecmd_pathre csh \\\\!\\*`; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; test 0 = \\\$_exit' ; -if \\\( \\\! \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval `$install_tclsh $modulecmd_pathre csh \\\\!\\*`; set _exit=\"\\\$status\"; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; -if \\\( \\\! \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'eval `$install_tclsh $modulecmd_pathre csh \\\\!\\*`;' ;" -set func_tcsh "if \\\( \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval `$install_tclsh $modulecmd_pathre tcsh \\\\!\\*`; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; -if \\\( \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; eval `$install_tclsh $modulecmd_pathre tcsh \\\\!\\*`; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; test 0 = \\\$_exit' ; -if \\\( \\\! \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval `$install_tclsh $modulecmd_pathre tcsh \\\\!\\*`; set _exit=\"\\\$status\"; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; -if \\\( \\\! \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'eval `$install_tclsh $modulecmd_pathre tcsh \\\\!\\*`;' ;" +set func_csh "if \\\( \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval \"`$install_tclsh $modulecmd_pathre csh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; +if \\\( \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; eval \"`$install_tclsh $modulecmd_pathre csh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; test 0 = \\\$_exit' ; +if \\\( \\\! \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval \"`$install_tclsh $modulecmd_pathre csh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; +if \\\( \\\! \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'eval \"`$install_tclsh $modulecmd_pathre csh \\\\!\\*:q`\";' ;" +set func_tcsh "if \\\( \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval \"`$install_tclsh $modulecmd_pathre tcsh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; +if \\\( \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'set _histchars = \\\$histchars; unset histchars; eval \"`$install_tclsh $modulecmd_pathre tcsh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set histchars = \\\$_histchars; unset _histchars; test 0 = \\\$_exit' ; +if \\\( \\\! \\\$\\\?histchars && \\\$\\\?prompt \\\) alias module 'set _prompt=\"\\\$prompt\"; set prompt=\"\"; eval \"`$install_tclsh $modulecmd_pathre tcsh \\\\!\\*:q`\"; set _exit=\"\\\$status\"; set prompt=\"\\\$_prompt\"; unset _prompt; test 0 = \\\$_exit' ; +if \\\( \\\! \\\$\\\?histchars && \\\! \\\$\\\?prompt \\\) alias module 'eval \"`$install_tclsh $modulecmd_pathre tcsh \\\\!\\*:q`\";' ;" set func_fish "function $func_name \\s*set -l _mlre ''; set -l _mlv; set -l _mlrv; \\s*for _mlv in \\\(string split ' ' \\\$MODULES_RUN_QUARANTINE\\\) From 070b3d9bfbba44ff2128f312bb3ccc8d9d1dbcd2 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 20 May 2018 09:07:09 +0200 Subject: [PATCH 06/28] ts: fix word splitting for zsh test in install suite --- testsuite/bin/install_test_sh | 4 ++++ testsuite/install.00-init/040-subshell.exp | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/testsuite/bin/install_test_sh b/testsuite/bin/install_test_sh index 7555ffae5..af8020323 100755 --- a/testsuite/bin/install_test_sh +++ b/testsuite/bin/install_test_sh @@ -91,6 +91,10 @@ fi # execute command list or perform recursive call case "$mode" in top|launch) + # enable word splitting for the below loop on zsh + if [ "$shname" = 'zsh' ]; then + setopt sh_word_split + fi IFS=';' for cmd in ${cmdlist}; do unset IFS diff --git a/testsuite/install.00-init/040-subshell.exp b/testsuite/install.00-init/040-subshell.exp index 00dddd795..e5deaf8d6 100644 --- a/testsuite/install.00-init/040-subshell.exp +++ b/testsuite/install.00-init/040-subshell.exp @@ -53,8 +53,8 @@ foreach shell $shell_list { zsh { testall_cmd_re "$shell" "module --version" "^\$" "$zsh_nf\$" 127 testall_cmd_re "$shell" "module foo" "^\$" "$zsh_nf\$" 127 - testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 127 - testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module unload null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 127 + testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 252 + testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module unload null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 123 } csh { testall_cmd_re "$shell" "module --version" "^\$" "$csh_nf\$" 1 @@ -101,8 +101,8 @@ foreach shell $shell_list { zsh { testall_cmd_re "$shell" "module --version" "^\$" "$zsh_nf\$" 127 testall_cmd_re "$shell" "module foo" "^\$" "$zsh_nf\$" 127 - testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 127 - testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module unload null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 127 + testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 252 + testall_cmd_re "$shell" "module use $contrib_modpath\; module purge\; module load null\; module unload null\; module list -t" "^\$" ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\$" 123 } csh { testall_cmd_re "$shell" "module --version" "^\$" "$csh_nf\$" 1 From 3975dcb6f6e52461da4aefef681bf09f17923132 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 20 May 2018 10:15:15 +0200 Subject: [PATCH 07/28] ts: fix special chars escaping code in values Add more special characters to the escaping list for regular shells. And fix code to over escape special characters relative to regular expression when regexp mode is enabled. --- testsuite/modules.00-init/006-procs.exp | 6 ++--- .../modules.50-cmds/042-append-delim.exp | 4 +-- .../modules.50-cmds/047-app-del-undo.exp | 2 +- .../modules.50-cmds/052-prepend-delim.exp | 4 +-- .../modules.50-cmds/057-pre-del-undo.exp | 2 +- .../modules.50-cmds/062-remove-delim.exp | 2 +- testsuite/modules.70-maint/120-autoinit.exp | 25 +++---------------- .../modules.70-maint/150-append-path.exp | 2 +- .../modules.70-maint/151-prepend-path.exp | 2 +- .../modules.70-maint/152-remove-path.exp | 2 +- 10 files changed, 16 insertions(+), 35 deletions(-) diff --git a/testsuite/modules.00-init/006-procs.exp b/testsuite/modules.00-init/006-procs.exp index d5c62dde4..de0c2c39b 100644 --- a/testsuite/modules.00-init/006-procs.exp +++ b/testsuite/modules.00-init/006-procs.exp @@ -219,8 +219,7 @@ proc shell_val {test_shell val {re_mode 0}} { if {$val ne "(.*)"} { switch -- $test_shell { {sh} - {bash} - {ksh} - {zsh} - {csh} - {tcsh} - {fish} { - set val [regsub -all {([\\$])} $val {\\\1}] - set val [regsub -all {([ ()])} $val {\\\\\1}] + set val [regsub -all {([\\"'$|{}`* ()!])} $val {\\\1}] } {lisp} - {cmake} { set val [regsub -all {(["])} $val {\\\1}] @@ -234,7 +233,8 @@ proc shell_val {test_shell val {re_mode 0}} { } if {$re_mode} { - set val [regsub -all {([+()])} $val {\\\1}] + # over escape regexp-special characters + set val [regsub -all {([$.+?\\()])} $val {\\\1}] } } diff --git a/testsuite/modules.50-cmds/042-append-delim.exp b/testsuite/modules.50-cmds/042-append-delim.exp index 5a7c5e221..7dc2a33ba 100644 --- a/testsuite/modules.50-cmds/042-append-delim.exp +++ b/testsuite/modules.50-cmds/042-append-delim.exp @@ -32,7 +32,7 @@ set ts_2 "http://foobar.net" set ts_3 "http://foobar.com" set ts_new "$ts_1 $ts_2 $ts_3" # test colon char is correctly escaped in _modshare var -set tsmod_new "http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.org:1" +set tsmod_new "http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.org:1" set env(testsuite) "$ts_1 $ts_2" set env(testsuite_modshare) "http\\://foobar.org:1:http\\://foobar.net:1" set module "append/1.0" @@ -87,7 +87,7 @@ testouterr_cmd "sh" "load $module" "ERR" $ts_err set module "append/1.6" set modulefile "$modpath/$module" set ts_new "$ts_1 $ts_2 $ts_3 http://foobar.io " -set tsmod_new ":1:http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.io:1:http\\\\://foobar.org:1" +set tsmod_new ":1:http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.io:1:http\\://foobar.org:1" set ans [list] lappend ans [list set testsuite_modshare $tsmod_new] diff --git a/testsuite/modules.50-cmds/047-app-del-undo.exp b/testsuite/modules.50-cmds/047-app-del-undo.exp index 069d9f15b..fedb6ae95 100644 --- a/testsuite/modules.50-cmds/047-app-del-undo.exp +++ b/testsuite/modules.50-cmds/047-app-del-undo.exp @@ -32,7 +32,7 @@ set ts_2 "http://foobar.net" set ts_3 "http://foobar.com" set ts_new "$ts_1 $ts_2" # test colon char is correctly escaped in _modshare var -set tsmod_new "http\\\\://foobar.net:1:http\\\\://foobar.org:1" +set tsmod_new "http\\://foobar.net:1:http\\://foobar.org:1" set module "append/1.0" set modulefile "$modpath/$module" diff --git a/testsuite/modules.50-cmds/052-prepend-delim.exp b/testsuite/modules.50-cmds/052-prepend-delim.exp index 5d4378bf6..d06b67340 100644 --- a/testsuite/modules.50-cmds/052-prepend-delim.exp +++ b/testsuite/modules.50-cmds/052-prepend-delim.exp @@ -32,7 +32,7 @@ set ts_2 "http://foobar.net" set ts_3 "http://foobar.com" set ts_new "$ts_3 $ts_1 $ts_2" # test colon char is correctly escaped in _modshare var -set tsmod_new "http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.org:1" +set tsmod_new "http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.org:1" set env(testsuite) "$ts_1 $ts_2" set env(testsuite_modshare) "http\\://foobar.org:1:http\\://foobar.net:1" set module "prepend/1.0" @@ -113,7 +113,7 @@ testouterr_cmd "sh" "load $module" "ERR" $ts_err set module "prepend/1.8" set modulefile "$modpath/$module" set ts_new " http://foobar.io $ts_3 $ts_1 $ts_2" -set tsmod_new ":1:http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.io:1:http\\\\://foobar.org:1" +set tsmod_new ":1:http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.io:1:http\\://foobar.org:1" set env(testsuite) "$ts_1 $ts_2" set env(testsuite_modshare) "http\\://foobar.org:1:http\\://foobar.net:1" diff --git a/testsuite/modules.50-cmds/057-pre-del-undo.exp b/testsuite/modules.50-cmds/057-pre-del-undo.exp index ed4f0dae4..d75def86a 100644 --- a/testsuite/modules.50-cmds/057-pre-del-undo.exp +++ b/testsuite/modules.50-cmds/057-pre-del-undo.exp @@ -32,7 +32,7 @@ set ts_2 "http://foobar.net" set ts_3 "http://foobar.com" set ts_new "$ts_1 $ts_2" # test colon char is correctly escaped in _modshare var -set tsmod_new "http\\\\://foobar.net:1:http\\\\://foobar.org:1" +set tsmod_new "http\\://foobar.net:1:http\\://foobar.org:1" set module "prepend/1.0" set modulefile "$modpath/$module" diff --git a/testsuite/modules.50-cmds/062-remove-delim.exp b/testsuite/modules.50-cmds/062-remove-delim.exp index c5d320f7c..d81e41db6 100644 --- a/testsuite/modules.50-cmds/062-remove-delim.exp +++ b/testsuite/modules.50-cmds/062-remove-delim.exp @@ -32,7 +32,7 @@ set ts_2 "http://foobar.net" set ts_3 "http://foobar.com" set ts_new "$ts_1 $ts_2" # test colon char is correctly escaped in _modshare var -set tsmod_new "http\\\\://foobar.net:1:http\\\\://foobar.org:1" +set tsmod_new "http\\://foobar.net:1:http\\://foobar.org:1" set env(testsuite) "$ts_1 $ts_2 $ts_3" set env(testsuite_modshare) "http\\://foobar.org:1:http\\://foobar.net:1:http\\://foobar.com:1" set module "remove/1.0" diff --git a/testsuite/modules.70-maint/120-autoinit.exp b/testsuite/modules.70-maint/120-autoinit.exp index 508e98b18..a33e8f43a 100644 --- a/testsuite/modules.70-maint/120-autoinit.exp +++ b/testsuite/modules.70-maint/120-autoinit.exp @@ -33,8 +33,6 @@ foreach elt [file split [file join [pwd] $MODULECMD]] { set modulecmd_path [eval file join $path_list] set modulecmd_pathre [regsub -all "\(\[.+?\]\)" $modulecmd_path {\\\1}] set moduleshome $install_prefix -set modulepathre [regsub -all "\(\[$.+?\]\)" $install_modulepath {\\\1}] -set install_prefixre [regsub -all {([$.+?])} $install_prefix {\\\1}] # compare init config files to determine if we can guess expected setup set insmodspath [file readable $install_initdir/.modulespath] @@ -450,12 +448,7 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle lappend ans [list set MODULEPATH_modshare "(.*)"] lappend ans [list set LOADEDMODULES ""] lappend ans [list set MODULESHOME $moduleshome] - # no re escaping for R (need re escaping to better cope with lang escaping) - if {$shell eq "r"} { - lappend ans [list set MODULEPATH "$modulepathre:$install_prefixre/test/modulefiles:$install_prefixre/test/etc" "noescval"] - } else { - lappend ans [list set MODULEPATH "$modulepathre:$install_prefix/test/modulefiles:$install_prefix/test/etc"] - } + lappend ans [list set MODULEPATH "$install_modulepath:$install_prefix/test/modulefiles:$install_prefix/test/etc"] if {$install_versioning eq "y"} { lappend ans [list set MODULE_VERSION "(.*)"] } @@ -466,21 +459,11 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle lappend ans [list set MODULE_VERSION_STACK "(.*)"] } lappend ans [list set MODULES_CMD $modulecmd_path] - # no re escaping for R (need re escaping to better cope with lang escaping) - if {$shell eq "r"} { - lappend ans [list set MODULEPATH_modshare "$modulepathre:1" "noescval"] - } else { - lappend ans [list set MODULEPATH_modshare "$modulepathre:1"] - } + lappend ans [list set MODULEPATH_modshare "$install_modulepath:1"] lappend ans [list set _LMFILES_ "$install_modulefilesdir/null"] lappend ans [list set LOADEDMODULES "null"] lappend ans [list set MODULESHOME $moduleshome] - # no re escaping for R (need re escaping to better cope with lang escaping) - if {$shell eq "r"} { - lappend ans [list set MODULEPATH "$modulepathre" "noescval"] - } else { - lappend ans [list set MODULEPATH "$modulepathre"] - } + lappend ans [list set MODULEPATH "$install_modulepath"] if {$install_versioning eq "y"} { lappend ans [list set MODULE_VERSION "(.*)"] } @@ -509,8 +492,6 @@ unset path_list unset modulecmd_pathre unset modulecmd_path unset moduleshome -unset modulepathre -unset install_prefixre if {[info exists fid]} { unset fid diff --git a/testsuite/modules.70-maint/150-append-path.exp b/testsuite/modules.70-maint/150-append-path.exp index 33476cf19..119ffe929 100644 --- a/testsuite/modules.70-maint/150-append-path.exp +++ b/testsuite/modules.70-maint/150-append-path.exp @@ -110,7 +110,7 @@ set env(FOO) "http://foobar.org,http://foobar.net" set ans [list] lappend ans [list set FOO "http://foobar.org,http://foobar.net,http://foobar.com,http://foobar.io,"] -lappend ans [list set FOO_modshare ":1:http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.io:1:http\\\\://foobar.org:1"] +lappend ans [list set FOO_modshare ":1:http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.io:1:http\\://foobar.org:1"] testouterr_cmd_re "sh" "append-path -d , FOO http://foobar.com,http://foobar.io," $ans "" testouterr_cmd_re "sh" "append-path -d , FOO http://foobar.com http://foobar.io," $ans "" diff --git a/testsuite/modules.70-maint/151-prepend-path.exp b/testsuite/modules.70-maint/151-prepend-path.exp index fe795e3dc..cd7c64041 100644 --- a/testsuite/modules.70-maint/151-prepend-path.exp +++ b/testsuite/modules.70-maint/151-prepend-path.exp @@ -110,7 +110,7 @@ set env(FOO) "http://foobar.org,http://foobar.net" set ans [list] lappend ans [list set FOO ",http://foobar.com,http://foobar.io,http://foobar.org,http://foobar.net"] -lappend ans [list set FOO_modshare ":1:http\\\\://foobar.com:1:http\\\\://foobar.net:1:http\\\\://foobar.io:1:http\\\\://foobar.org:1"] +lappend ans [list set FOO_modshare ":1:http\\://foobar.com:1:http\\://foobar.net:1:http\\://foobar.io:1:http\\://foobar.org:1"] testouterr_cmd_re "sh" "prepend-path -d , FOO ,http://foobar.com,http://foobar.io" $ans "" testouterr_cmd_re "sh" "prepend-path -d , FOO ,http://foobar.com http://foobar.io" $ans "" diff --git a/testsuite/modules.70-maint/152-remove-path.exp b/testsuite/modules.70-maint/152-remove-path.exp index d58d61bb1..8f55a1daf 100644 --- a/testsuite/modules.70-maint/152-remove-path.exp +++ b/testsuite/modules.70-maint/152-remove-path.exp @@ -123,7 +123,7 @@ set env(FOO) ",http://foobar.com,http://foobar.io,http://foobar.org,http://fooba set ans [list] lappend ans [list set FOO "http://foobar.org,http://foobar.net"] -lappend ans [list set FOO_modshare "http\\\\://foobar.net:1:http\\\\://foobar.org:1"] +lappend ans [list set FOO_modshare "http\\://foobar.net:1:http\\://foobar.org:1"] testouterr_cmd_re "sh" "remove-path -d , FOO ,http://foobar.com,http://foobar.io" $ans "" testouterr_cmd_re "sh" "remove-path -d , FOO ,http://foobar.com http://foobar.io" $ans "" From 810e9efff0b7947513210bf1306c5ff2a2bbf1cc Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 20 May 2018 14:44:48 +0200 Subject: [PATCH 08/28] Define shell alias with special chars escaped When producing code to output shell alias definition, escaping of special characters was missing until now in renderSettings procedure. Code to bake shell alias has been fixed to work in a similar way than for environment variable with full range of shell special characters escaped. Translation of $n/$* in !!:n/!* on csh-like shells is maintained for compatibility with v3. To improve this compatibility, a \ prior to $ disables translation on csh (like with v3), then after \$ is translated in $ for all shells. Adapt testsuite to use value escaping over expected output result for shell alias (like done for environment variable). Adapt consequently all shell alias tests in 50-cmds/07*. Add test in 50-cmds/076-alias-sub to demonstrate escaping of complex shell alias. Use modulefile from this new test within install testsuite to garanty shell alias produce is effective on shell sessions. Check availability of tools used by this alias (grep, tr, awk) to determine if install test can be launched on current system. Fixes #165 --- modulecmd.tcl.in | 26 ++++----- testsuite/bin/install_test_sh | 5 +- testsuite/install.00-init/005-init_ts.exp | 3 +- testsuite/install.00-init/020-module.exp | 9 ++++ testsuite/modulefiles/alias/3.0 | 35 +++++++++++++ testsuite/modules.00-init/006-procs.exp | 10 ++-- testsuite/modules.50-cmds/075-alias.exp | 2 +- testsuite/modules.50-cmds/076-alias-sub.exp | 58 +++++++++++++++++---- testsuite/modules.90-avail/070-full.exp | 8 +-- 9 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 testsuite/modulefiles/alias/3.0 diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index ff72840a6..4c63ad40a 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -3150,26 +3150,28 @@ proc renderSettings {} { foreach var [array names g_stateAliases] { switch -- $g_stateAliases($var) { {new} { + set val $::g_Aliases($var) + # convert $n in !!:n and $* in !* on csh (like on compat version) + if {$::g_shellType eq "csh"} { + regsub -all {([^\\]|^)\$([0-9]+)} $val {\1!!:\2} val + regsub -all {([^\\]|^)\$\*} $val {\1!*} val + } + # unescape \$ after now csh-specific conversion is over + regsub -all {\\\$} $val {$} val switch -- $::g_shellType { {csh} { - # set val [charEscaped $::g_Aliases($var)] - set val $::g_Aliases($var) - # Convert $n -> \!\!:n - regsub -all {\$([0-9]+)} $val {\\!\\!:\1} val - # Convert $* -> \!* - regsub -all {\$\*} $val {\\!*} val - puts stdout "alias $var '$val';" + set val [charEscaped $val] + puts stdout "alias $var $val;" } {sh} { - set val $::g_Aliases($var) - puts stdout "alias $var='$val';" + set val [charEscaped $val] + puts stdout "alias $var=$val;" } {fish} { - set val $::g_Aliases($var) - puts stdout "alias $var '$val';" + set val [charEscaped $val] + puts stdout "alias $var $val;" } {cmd} { - set val $::g_Aliases($var) puts stdout "doskey $var=$val" } } diff --git a/testsuite/bin/install_test_sh b/testsuite/bin/install_test_sh index af8020323..c54e6fab5 100755 --- a/testsuite/bin/install_test_sh +++ b/testsuite/bin/install_test_sh @@ -91,8 +91,11 @@ fi # execute command list or perform recursive call case "$mode" in top|launch) + # enable alias resolution on bash for tests + if [ "$shname" = 'bash' ]; then + shopt -s expand_aliases # enable word splitting for the below loop on zsh - if [ "$shname" = 'zsh' ]; then + elif [ "$shname" = 'zsh' ]; then setopt sh_word_split fi IFS=';' diff --git a/testsuite/install.00-init/005-init_ts.exp b/testsuite/install.00-init/005-init_ts.exp index 2b340cdb0..dc6218bbc 100644 --- a/testsuite/install.00-init/005-init_ts.exp +++ b/testsuite/install.00-init/005-init_ts.exp @@ -179,8 +179,9 @@ foreach shell [list sh bash basheu ksh zsh csh tcsh fish tcl perl python ruby cm # where to find module tcl script to call for autoinit command set autoinit_script "$install_libexecdir/modulecmd.tcl" -# where to find contrib modulefiles for test +# where to find modulefiles for test set contrib_modpath "$env(TESTSUITEDIR)/../contrib/modulefiles" +set testsuite_modpath "$env(TESTSUITEDIR)/modulefiles" # basic messages set type_help "Try 'module --help' for more information." diff --git a/testsuite/install.00-init/020-module.exp b/testsuite/install.00-init/020-module.exp index 17b8a743a..e6e61166f 100644 --- a/testsuite/install.00-init/020-module.exp +++ b/testsuite/install.00-init/020-module.exp @@ -41,6 +41,15 @@ foreach shell $shell_list { testall_cmd "$shell" "module use $contrib_modpath\; module load null\; module info-loaded null" "null" "" 0 } +# ensure tools used in complex shell alias definition are available +if {[find_bin grep] ne "" && [find_bin tr] ne "" && [find_bin awk] ne ""} { + foreach shell $shell_list { + testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite" "Release" ".*" 0 + } +} elseif {$verbose > 0} { + send_user "\tSkipping shell alias definition tests\n" +} + foreach shell $othlang_list { testall_cmd_re "$shell" "--version" "^\$" "^Modules Release \\S+ (\\S+)\$" 0 testall_cmd_re "$shell" "foo" "^\$" "$bad_cmd\n$type_help.*" 1 diff --git a/testsuite/modulefiles/alias/3.0 b/testsuite/modulefiles/alias/3.0 new file mode 100644 index 000000000..90b392e0c --- /dev/null +++ b/testsuite/modulefiles/alias/3.0 @@ -0,0 +1,35 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: alias/%M% +# Revision: %I% +# First Edition: 2018/05/19 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle +# +# Description: Testuite modulefile +# Command: +# Sub-Command: set-alias +# +# Comment: %C{ +# Check how special characters in alias definition are handled +# }C% +# +############################################################################## + +switch -- [module-info shelltype] { + {sh} { + set-alias testsuite {echo $(grep "report \"Modules " modulecmd.tcl | tr -d \\ | awk '{print \$3}')} + } + {csh} { + set-alias testsuite {echo `grep "report "'"'"Modules " modulecmd.tcl | tr -d \\ | awk '{print \$3}'`} + } + {fish} { + set-alias testsuite {echo (grep "report \"Modules " modulecmd.tcl | tr -d \\ | awk '{print \$3}')} + } +} + diff --git a/testsuite/modules.00-init/006-procs.exp b/testsuite/modules.00-init/006-procs.exp index de0c2c39b..e2693fead 100644 --- a/testsuite/modules.00-init/006-procs.exp +++ b/testsuite/modules.00-init/006-procs.exp @@ -347,19 +347,23 @@ proc shell_unset {test_shell var {re_mode 0}} { return $answer } -proc shell_alias {test_shell var val {re_mode 0}} { +proc shell_alias {test_shell var val {re_mode 0} {escval 1}} { if {$re_mode} { set esc "\\" } else { set esc "" } + if {$escval} { + set val [shell_val $test_shell $val $re_mode] + } + switch -- $test_shell { {sh} - {bash} - {ksh} - {zsh} { - set answer "alias $var='$val';" + set answer "alias $var=$val;" } {csh} - {tcsh} - {fish} { - set answer "alias $var '$val';" + set answer "alias $var $val;" } {cmd} { set answer "doskey $var=$val" diff --git a/testsuite/modules.50-cmds/075-alias.exp b/testsuite/modules.50-cmds/075-alias.exp index a8ed23022..6a1b0ca3e 100644 --- a/testsuite/modules.50-cmds/075-alias.exp +++ b/testsuite/modules.50-cmds/075-alias.exp @@ -29,7 +29,7 @@ set module "alias/2.0" set modulefile "$modpath/$module" -set alias "ps -auxww \| grep modulecmd" +set alias "ps -auxww | grep modulecmd" # # For the different shells ... diff --git a/testsuite/modules.50-cmds/076-alias-sub.exp b/testsuite/modules.50-cmds/076-alias-sub.exp index b9d08ec8b..9116927f6 100644 --- a/testsuite/modules.50-cmds/076-alias-sub.exp +++ b/testsuite/modules.50-cmds/076-alias-sub.exp @@ -15,7 +15,7 @@ # Sub-Command: # # Comment: %C{ -# Tests the 'set-alias' substition of $1 and $* +# Tests the 'set-alias' substition of $1 and $* and special chars # }C% # ############################################################################## @@ -28,15 +28,15 @@ set module "alias/1.0" set modulefile "$modpath/$module" -set alias_sh {ls \$1 \$2 \| grep \$\*} -set alias_csh {ls \\!\\!:1 \\!\\!:2 \| grep \\!\*} -set alias_cmd {ls $1 $2 | grep $*} +set alias {ls $1 $2 | grep $*} +set alias_csh {ls !!:1 !!:2 | grep !*} + # # For the different shells ... # -lappend ans [list alias testsuite $alias_sh] +lappend ans [list alias testsuite $alias] lappend ans [list setpath LOADEDMODULES $module] lappend ans [list setpath _LMFILES_ $modulefile] @@ -44,7 +44,7 @@ lappend ans2 [list alias testsuite $alias_csh] lappend ans2 [list setpath LOADEDMODULES $module] lappend ans2 [list setpath _LMFILES_ $modulefile] -lappend ans3 [list alias testsuite $alias_cmd] +lappend ans3 [list alias testsuite $alias] lappend ans3 [list setpath LOADEDMODULES $module] lappend ans3 [list setpath _LMFILES_ $modulefile] @@ -60,12 +60,51 @@ foreach sh $supported_shells { if {$sh eq "cmd"} { test_cmd "$sh" "load $module" $ans3 } elseif {[lsearch -exact $csh_shells $sh] >= 0} { - test_cmd_re "$sh" "load $module" $ans2 + test_cmd "$sh" "load $module" $ans2 } else { - test_cmd_re "$sh" "load $module" $ans + test_cmd "$sh" "load $module" $ans + } +} + + +# +# Test special characters handling +# + +set module "alias/3.0" +set modulefile "$modpath/$module" + +set ans [list] +lappend ans [list alias testsuite {echo $(grep "report \"Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}] +lappend ans [list setpath LOADEDMODULES $module] +lappend ans [list setpath _LMFILES_ $modulefile] + +set ans2 [list] +lappend ans2 [list alias testsuite {echo `grep "report "'"'"Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}'`}] +lappend ans2 [list setpath LOADEDMODULES $module] +lappend ans2 [list setpath _LMFILES_ $modulefile] + +set ans3 [list] +lappend ans3 [list alias testsuite {echo (grep "report \"Modules " modulecmd.tcl | tr -d \\ | awk '{print $3}')}] +lappend ans3 [list setpath LOADEDMODULES $module] +lappend ans3 [list setpath _LMFILES_ $modulefile] + + +foreach sh $supported_shells { + switch -- $sh { + {sh} - {bash} - {ksh} - {zsh} { + test_cmd $sh "load $module" $ans + } + {csh} - {tcsh} { + test_cmd $sh "load $module" $ans2 + } + {fish} { + test_cmd $sh "load $module" $ans3 + } } } + # # Cleanup # @@ -77,7 +116,6 @@ unset ans3 unset modulefile unset module -unset alias_sh +unset alias unset alias_csh -unset alias_cmd diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 9ed543c5f..48ae4b434 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -41,8 +41,9 @@ set len [string length $modpath] set lrep [expr {($test_cols - $len - 2)/2}] set rrep [expr {$test_cols - $len - 2 - $lrep}] set ts_sh "[string repeat {-} $lrep] $modpath [string repeat {-} $rrep] -alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/5.0 -alias/2.0 info/type loc_sym/alias2 modbad/is-saved spread/6.0 +alias/1.0 info/shellsexp loc_sym/1.0 modbad/is-avail spread/4.0 +alias/2.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/5.0 +alias/3.0 info/type loc_sym/alias2 modbad/is-saved spread/6.0 append/0.1 info/user loc_sym/alias3 modbad/is-used spread/7.0 append/0.2 info/userexp loc_sym/alias4 modbad/path spread/8.0 append/0.3 inforc/1.0 loc_sym/alias5 modbad/paths spreadrc/dir1/1.0 @@ -122,8 +123,7 @@ info/mode5 loc_rcv1/2.0 modbad/autoinit info/mode6 loc_rcv1/bar(@) modbad/empty source/1.2 whatis/none info/name loc_rcv2/1.2 modbad/foo spread/1.0 whatis/single info/others loc_rcv2/1.5 modbad/help spread/2.0 whatis/string -info/shells loc_rcv2/2.0 modbad/info-loaded spread/3.0 x-resource/1 -info/shellsexp loc_sym/1.0 modbad/is-avail spread/4.0 " +info/shells loc_rcv2/2.0 modbad/info-loaded spread/3.0 x-resource/1 " set ts_sh_small "- $modpath.deep - dir2/1.0(d1) From 464289b60bfd72464f3940dfd3f74a2b7598a900 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 24 May 2018 05:49:11 +0200 Subject: [PATCH 09/28] If subdir is empty do not update parent dir if overwritten During a modulefile lookup in getModules, directory definitions are updated if some empty directories are found in them. Do not attempt this directory definition update when finding an empty directory if parent directory has been overwritten by an alias definition for instance. Fixes #170 --- modulecmd.tcl.in | 4 +++ .../modulefiles.deep/moddalias/.modulerc | 28 ++++++++++++++++ testsuite/modulefiles.deep/moddalias/dir1/1 | 28 ++++++++++++++++ .../modulefiles.deep/moddalias/dir2/.ignored | 1 + testsuite/modules.80-deep/010-init_ts.exp | 6 ++++ testsuite/modules.80-deep/020-load.exp | 12 +++++++ testsuite/modules.80-deep/021-unload.exp | 17 ++++++++++ testsuite/modules.80-deep/030-display.exp | 3 ++ testsuite/modules.80-deep/050-whatis.exp | 3 ++ testsuite/modules.80-deep/999-cleanup.exp | 6 ++++ testsuite/modules.90-avail/070-full.exp | 32 +++++++++++-------- 11 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 testsuite/modulefiles.deep/moddalias/.modulerc create mode 100644 testsuite/modulefiles.deep/moddalias/dir1/1 create mode 100644 testsuite/modulefiles.deep/moddalias/dir2/.ignored diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 4c63ad40a..91424e112 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -4385,6 +4385,10 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {fetch_hidden 0}} { && [info exists mod_list($par_dir)]} { set dir_name [file tail $dir] set dir $par_dir + # quit if something has overwritten the directory definition + if {[lindex $mod_list($dir) 0] ne "directory"} { + break + } # get upper dir content without empty dir (as dir_list is sorted # parent dir information have already been consolidated) set elt_list [lsearch -all -inline -not -exact [lrange\ diff --git a/testsuite/modulefiles.deep/moddalias/.modulerc b/testsuite/modulefiles.deep/moddalias/.modulerc new file mode 100644 index 000000000..51d4a1dfd --- /dev/null +++ b/testsuite/modulefiles.deep/moddalias/.modulerc @@ -0,0 +1,28 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: moddalias/%M% +# Revision: %I% +# First Edition: 2018/05/24 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: +# Sub-Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# Test alias is correctly resolved when it overwrites a directory +# and an empty directory is a child of this overwritten directory +# }C% +# +############################################################################## + +module-alias moddalias moddalias/dir1 diff --git a/testsuite/modulefiles.deep/moddalias/dir1/1 b/testsuite/modulefiles.deep/moddalias/dir1/1 new file mode 100644 index 000000000..3ee6715e3 --- /dev/null +++ b/testsuite/modulefiles.deep/moddalias/dir1/1 @@ -0,0 +1,28 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: moddalias/%M% +# Revision: %I% +# First Edition: 2018/05/24 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: +# Sub-Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# Test alias is correctly resolved when it overwrites a directory +# and an empty directory is a child of this overwritten directory +# }C% +# +############################################################################## + +module-whatis [module-info name] diff --git a/testsuite/modulefiles.deep/moddalias/dir2/.ignored b/testsuite/modulefiles.deep/moddalias/dir2/.ignored new file mode 100644 index 000000000..1bc89295f --- /dev/null +++ b/testsuite/modulefiles.deep/moddalias/dir2/.ignored @@ -0,0 +1 @@ +# not modulefile diff --git a/testsuite/modules.80-deep/010-init_ts.exp b/testsuite/modules.80-deep/010-init_ts.exp index 8ec992fb2..8319d7e50 100644 --- a/testsuite/modules.80-deep/010-init_ts.exp +++ b/testsuite/modules.80-deep/010-init_ts.exp @@ -102,3 +102,9 @@ set ivirt7 "modvirt/dir0/sub1" set ovirt7 "modvirt/dir0/sub1/6.0" set ivirt8 "modvirt/dir0" set ovirt8 "modvirt/dir0/sub1/6.0" + +set cdalias "moddalias" +set idalias0 "moddalias" +set odalias0 "moddalias/dir1/1" +set idalias1 "moddalias/dir1" +set odalias1 "moddalias/dir1/1" diff --git a/testsuite/modules.80-deep/020-load.exp b/testsuite/modules.80-deep/020-load.exp index 3a6c91f80..ca6c5cbfb 100644 --- a/testsuite/modules.80-deep/020-load.exp +++ b/testsuite/modules.80-deep/020-load.exp @@ -188,6 +188,18 @@ lappend ans [list setpath LOADEDMODULES $ovirt8] lappend ans [list setpath _LMFILES_ "$pvirt"] test_cmd_re "csh" "load $ivirt8" $ans + +set ans [list] +lappend ans [list setpath LOADEDMODULES $odalias0] +lappend ans [list setpath _LMFILES_ "$p$odalias0"] +test_cmd_re "csh" "load $idalias0" $ans + +set ans [list] +lappend ans [list setpath LOADEDMODULES $odalias1] +lappend ans [list setpath _LMFILES_ "$p$odalias1"] +test_cmd_re "csh" "load $idalias1" $ans + + unset p unset ans diff --git a/testsuite/modules.80-deep/021-unload.exp b/testsuite/modules.80-deep/021-unload.exp index 6187d72c4..7925f30f3 100644 --- a/testsuite/modules.80-deep/021-unload.exp +++ b/testsuite/modules.80-deep/021-unload.exp @@ -36,6 +36,8 @@ set module_7 "modvirt/3.0" set modulefile_7 "$modulefile_5" set module_8 "modvirt/dir0/sub1/4.0" set modulefile_8 "$modulefile_5" +set module_9 "moddalias/dir1/1" +set modulefile_9 "$modpath/$module_9" # @@ -210,6 +212,19 @@ testouterr_cmd "sh" "unload modvirt/dir0" $ans "" testouterr_cmd "sh" "unload modvirt" $ans "" +# set up the environment +set env(_LMFILES_) "$modulefile_9" +set env(LOADEDMODULES) "$module_9" + +set ans [list] +lappend ans [list unsetpath LOADEDMODULES] +lappend ans [list unsetpath _LMFILES_] + +testouterr_cmd "sh" "unload $module_9" $ans "" +testouterr_cmd "sh" "unload moddalias/dir1" $ans "" +testouterr_cmd "sh" "unload moddalias" $ans "" + + # # Cleanup # @@ -235,3 +250,5 @@ unset module_7 unset modulefile_7 unset module_8 unset modulefile_8 +unset module_9 +unset modulefile_9 diff --git a/testsuite/modules.80-deep/030-display.exp b/testsuite/modules.80-deep/030-display.exp index 5caa8a54b..1823bda2c 100644 --- a/testsuite/modules.80-deep/030-display.exp +++ b/testsuite/modules.80-deep/030-display.exp @@ -60,6 +60,9 @@ testouterr_cmd_re "csh" "display $ivirt6" "OK" "$modlin\n$pvirtre$mw$ovirt6$sv$o testouterr_cmd_re "csh" "display $ivirt7" "OK" "$modlin\n$pvirtre$mw$ovirt7$sv$ovirt7$nl" testouterr_cmd_re "csh" "display $ivirt8" "OK" "$modlin\n$pvirtre$mw$ovirt8$sv$ovirt8$nl" +testouterr_cmd_re "csh" "display $idalias0" "OK" "$modlin\n$p$odalias0$mw$odalias0$nl" +testouterr_cmd_re "csh" "display $idalias1" "OK" "$modlin\n$p$odalias1$mw$odalias1$nl" + unset p unset lmf diff --git a/testsuite/modules.80-deep/050-whatis.exp b/testsuite/modules.80-deep/050-whatis.exp index 2442752ea..b5d015c8b 100644 --- a/testsuite/modules.80-deep/050-whatis.exp +++ b/testsuite/modules.80-deep/050-whatis.exp @@ -29,4 +29,7 @@ testouterr_cmd_re "csh" "whatis $ivirt6" "OK" "$header\n\\s*$ovirt6: $ovirt6" testouterr_cmd_re "csh" "whatis $ivirt7" "OK" "$header\n\\s*$ovirt5: $ovirt5\\s*$ovirt6: $ovirt6\\s*$ovirt7: $ovirt7" testouterr_cmd_re "csh" "whatis $ivirt8" "OK" "$header\n\\s*$ovirt5: $ovirt5\\s*$ovirt6: $ovirt6\\s*$ovirt8: $ovirt8" +testouterr_cmd_re "csh" "whatis $idalias0" "OK" "$header\n $odalias0: $odalias0" +testouterr_cmd_re "csh" "whatis $idalias1" "OK" "$header\n $odalias1: $odalias1" + unset header diff --git a/testsuite/modules.80-deep/999-cleanup.exp b/testsuite/modules.80-deep/999-cleanup.exp index 286489cfc..a22257749 100644 --- a/testsuite/modules.80-deep/999-cleanup.exp +++ b/testsuite/modules.80-deep/999-cleanup.exp @@ -99,3 +99,9 @@ unset ivirt7 unset ovirt7 unset ivirt8 unset ovirt8 + +unset cdalias +unset idalias0 +unset odalias0 +unset idalias1 +unset odalias1 diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 48ae4b434..03a04a5f0 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -134,6 +134,8 @@ modalias/dir1/1.0 modalias/dir1/2.0(@) modalias/dir2/2.0 modalias/dir2/3.0(@) +moddalias(@) +moddalias/dir1/1 moddef/dir2/1.0(default) moddef/dir2/2.0 modload/dir2/1.0(md1) @@ -202,6 +204,8 @@ modalias/dir1/1.0 modalias/dir1/2.0 modalias/dir2/2.0 modalias/dir2/3.0 +moddalias +moddalias/dir1/1 moddef/dir2/1.0 moddef/dir2/2.0 modload/dir2/1.0 @@ -265,20 +269,20 @@ set len [string length $modpath.deep] set lrep [expr {($test_cols_othos - $len - 2)/2}] set rrep [expr {$test_cols_othos - $len - 2 - $lrep}] set ts_sh_noflag_othos "[string repeat {-} $lrep] $modpath.deep [string repeat {-} $rrep] -dir2/1.0 modtr/3.0 modtr/dir5/subdir/mod5.0 modvirt/dir1/1.0 trmod/dir3 -dir2/3.0 modtr/al1 modulerc/dir1 modvirt/dir1/2.0 trmod/dir3/al2 -modalias/1.0 modtr/al4 modulerc/dir1/1.0 modvirt/dir2/2.0 version/dir1 -modalias/3.0 modtr/al5 modulerc/dir1/2.0 modvirt/dir2/3.0 version/dir1/1.0 -modalias/dir1/1.0 modtr/al6 modulerc/dir2/1.0 plain/dir1/1.0 version/dir1/2.0 -modalias/dir1/2.0 modtr/dir1/1.0 modulerc/dir2/1.0/rc1 plain/dir1/2.0 version/dir2/1.0 -modalias/dir2/2.0 modtr/dir2/2.0 modulerc/dir2/1.0/rc2 plain/dir2/1.0 version/dir2/2.0 -modalias/dir2/3.0 modtr/dir3/al2 modulerc/dir2/2.0 plain/dir2/2.0 version/dir2/2.0/rc1 -moddef/dir2/1.0 modtr/dir3/al3 modulerc/dir2/3.0 tr2mod/al1 version/dir2/2.0/rc2 -moddef/dir2/2.0 modtr/dir4 modvirt/1.0 tr2mod/al5 version/dir2/3.0 -modload/dir2/1.0 modtr/dir4/al7 modvirt/3.0 tr2mod/dir3/al2 -modload/dir2/3.0 modtr/dir4/al8 modvirt/dir0/sub1/4.0 trmod -modsym/dir1/1.0 modtr/dir4/mod4.0 modvirt/dir0/sub1/5.0 trmod/al1 -modsym/dir2/2.0 modtr/dir5/subdir modvirt/dir0/sub1/6.0 trmod/al5 " +dir2/1.0 modsym/dir1/1.0 modtr/dir4/mod4.0 modvirt/dir0/sub1/5.0 trmod/al1 +dir2/3.0 modsym/dir2/2.0 modtr/dir5/subdir modvirt/dir0/sub1/6.0 trmod/al5 +modalias/1.0 modtr/3.0 modtr/dir5/subdir/mod5.0 modvirt/dir1/1.0 trmod/dir3 +modalias/3.0 modtr/al1 modulerc/dir1 modvirt/dir1/2.0 trmod/dir3/al2 +modalias/dir1/1.0 modtr/al4 modulerc/dir1/1.0 modvirt/dir2/2.0 version/dir1 +modalias/dir1/2.0 modtr/al5 modulerc/dir1/2.0 modvirt/dir2/3.0 version/dir1/1.0 +modalias/dir2/2.0 modtr/al6 modulerc/dir2/1.0 plain/dir1/1.0 version/dir1/2.0 +modalias/dir2/3.0 modtr/dir1/1.0 modulerc/dir2/1.0/rc1 plain/dir1/2.0 version/dir2/1.0 +moddalias modtr/dir2/2.0 modulerc/dir2/1.0/rc2 plain/dir2/1.0 version/dir2/2.0 +moddalias/dir1/1 modtr/dir3/al2 modulerc/dir2/2.0 plain/dir2/2.0 version/dir2/2.0/rc1 +moddef/dir2/1.0 modtr/dir3/al3 modulerc/dir2/3.0 tr2mod/al1 version/dir2/2.0/rc2 +moddef/dir2/2.0 modtr/dir4 modvirt/1.0 tr2mod/al5 version/dir2/3.0 +modload/dir2/1.0 modtr/dir4/al7 modvirt/3.0 tr2mod/dir3/al2 +modload/dir2/3.0 modtr/dir4/al8 modvirt/dir0/sub1/4.0 trmod " # # test From 12d65b4f65fd8f5ab4dd2ce5312cb99d4ada2a83 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 1 Jun 2018 20:57:12 +0200 Subject: [PATCH 10/28] doc: desc. 'getenv' command in modulefile(4) man --- doc/source/modulefile.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/modulefile.rst b/doc/source/modulefile.rst index 273d15baa..8834d416f 100644 --- a/doc/source/modulefile.rst +++ b/doc/source/modulefile.rst @@ -132,6 +132,11 @@ the *modulefile* is being loaded. then when unloading a module, it will set *variable* to *value*. The **unsetenv** command changes the process' environment like **setenv**. +**getenv** variable + +Returns value of environment *variable*. If *variable* is not defined +*_UNDEFINED_* is returned. + **append-path** [-d C|--delim C|--delim=C] [--duplicates] variable value... See **prepend-path**. From 443a83efd697802b797f06f654c31a485dfa866c Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 17 Jun 2018 09:33:34 +0200 Subject: [PATCH 11/28] Detect shell with variables in profile.sh script To improve shell detection code that until now was relying on a parent process name check, some shell variables will be used to determine the current shell name. $BASH and $ZSH_NAME variables will be looked at if defined to determine calling shell name. Doing so will avoid some external command call when running bash or zsh. Also if people source /etc/profile script in their own bash or zsh script it will correctly determine calling shell name, as parent process in this case is the script name. Cannot determine shell name on ksh with a variable due to the lack of a consistent detection mechanism across all ksh flavors [1]. Fixes #173 [1] https://books.google.fr/books?id=53zaxy423xcC&pg=PA161 --- init/profile.sh.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/init/profile.sh.in b/init/profile.sh.in index b68519bb4..6926f5cbf 100644 --- a/init/profile.sh.in +++ b/init/profile.sh.in @@ -1,4 +1,12 @@ -shell=$(@BASENAME@ $(@PS@ -p $$ -ocomm=)) +# get current shell name by querying shell variables or looking at parent +# process name +if [ -n "${BASH:-}" ]; then + shell=${BASH##*/} +elif [ -n "${ZSH_NAME:-}" ]; then + shell=$ZSH_NAME +else + shell=$(@BASENAME@ $(@PS@ -p $$ -ocomm=)) +fi if [ -f @initdir@/$shell ]; then . @initdir@/$shell From c2634ac1b85641b1e4c02e2a4f5f09b657385ef7 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Mon, 18 Jun 2018 05:23:50 +0200 Subject: [PATCH 12/28] Release of version 4.1.3 --- NEWS.rst | 22 ++++++++++++++++++++++ contrib/rpm/environment-modules.spec.in | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 9304d6282..6422f1ca5 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,28 @@ This file describes changes in recent versions of Modules. It primarily documents those changes that are of interest to users and admins. +Modules 4.1.3 (2018-06-18) +-------------------------- + +* Make ``setenv`` command alter ``env`` Tcl global array during ``help``, + ``test`` or ``whatis`` evaluation modes. (fix issue#160) +* Doc: describe MANPATH variable special treatment on compatibility version + in diff_v3_v4 document. +* Initialize and export _moduleraw SH shell function if ``stderr`` is attached + to a terminal. Was previously checking ``stdout``. (fix issue#169) +* For ``csh`` shells, quote code generated by modulecmd.tcl to pass it to the + ``eval`` shell command. +* Escape special characters when producing code to define shell aliases (fix + issue#165) +* Correct modulefile lookup when a modulefile directory is overwritten by a + module alias definition but it contains an empty sub-directory. (fix + issue#170) +* Doc: describe ``getenv`` command in modulefile(4) man page. +* Improve SH shell detection in profile.sh initialization script to use shell + variable on ``bash`` or ``zsh`` to determine current shell name. (fix + issue#173) + + Modules 4.1.2 (2018-03-31) -------------------------- diff --git a/contrib/rpm/environment-modules.spec.in b/contrib/rpm/environment-modules.spec.in index 4f561f784..81c78ae52 100644 --- a/contrib/rpm/environment-modules.spec.in +++ b/contrib/rpm/environment-modules.spec.in @@ -1,7 +1,7 @@ %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) Name: environment-modules -Version: 4.1.2 +Version: 4.1.3 Release: @MODULES_RPM_RELEASE@%{?dist} Summary: Provides dynamic modification of a user's environment @@ -217,6 +217,9 @@ fi %changelog +* Mon Jun 18 2018 Xavier Delaruelle - 4.1.3-1 +- Update to 4.1.3 + * Sat Mar 31 2018 Xavier Delaruelle - 4.1.2-1 - Update to 4.1.2 From 643456c623520c0c99ecf7df75a1802d4d6fa8e4 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sat, 30 Jun 2018 22:18:50 +0200 Subject: [PATCH 13/28] install: relax GNU grep requirement constraint Rely on regular grep options rather grep -P to better cope with OSes where BSD grep is available by default. --- Makefile | 4 ++-- Makefile.inc.in | 1 - configure | 12 ++---------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 9e0f7c10b..8149fdadc 100644 --- a/Makefile +++ b/Makefile @@ -69,8 +69,8 @@ MODULES_RELEASE_SUFFIX := else MODULES_RELEASE_SUFFIX := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_RELEASE)) endif -MODULES_LAST_RPM_VERSREL := $(shell $(GREP) -Pzo -m 1 '%changelog\n+\*.* - \K.*\n' \ - contrib/rpm/environment-modules.spec.in) +MODULES_LAST_RPM_VERSREL := $(shell grep -A 1 '%changelog' \ + contrib/rpm/environment-modules.spec.in | grep '^* ' | grep -Eo '\S+$$') MODULES_LAST_RPM_RELEASE := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_LAST_RPM_VERSREL)) ifneq ($(MODULES_RELEASE_SUFFIX),) diff --git a/Makefile.inc.in b/Makefile.inc.in index 67acdf559..a7f532780 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -53,6 +53,5 @@ TCLSH := @TCLSH@ SPHINXBUILD := @SPHINXBUILD@ PS := @PS@ BASENAME := @BASENAME@ -GREP := @GREP@ RMDIR_IGN_NON_EMPTY := @RMDIR_IGN_NON_EMPTY@ diff --git a/configure b/configure index e97299f63..f65d00778 100755 --- a/configure +++ b/configure @@ -26,7 +26,7 @@ prog=${progpath##*/} targetlist="${progdir}/Makefile.inc ${progdir}/site.exp" # argument list -arglist="TCLSH SPHINXBUILD PS BASENAME GREP RMDIR_IGN_NON_EMPTY VERSION \ +arglist="TCLSH SPHINXBUILD PS BASENAME RMDIR_IGN_NON_EMPTY VERSION \ baseprefix prefix bindir libexecdir etcdir initdir datarootdir mandir docdir \ modulefilesdir setmanpath setbinpath setdotmodulespath docinstall \ examplemodulefiles builddoc gitworktree usemanpath compatversion EXEEXT \ @@ -57,7 +57,6 @@ gitworktree=y usemanpath=y PS=ps BASENAME=basename -GREP=grep RMDIR_IGN_NON_EMPTY=rmdir VERSION= pager=less @@ -329,14 +328,7 @@ case "$kernelname" in esac check_requirement $make check_requirement sed -# ensure a GNU grep is used on Solaris and Darwin -if [ "$kernelname" = 'SunOS' -o "$kernelname" = 'Darwin' ]; then - grep='ggrep' -else - grep='grep' -fi -check_requirement $grep -GREP=$reqpath +check_requirement grep check_requirement cut check_requirement runtest "Install \`dejagnu' if you want to run the \ testsuite" From d06a2b35bdfbd22174545dd51e2324546ac19a41 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sat, 30 Jun 2018 22:23:32 +0200 Subject: [PATCH 14/28] doc: fix getenv desc. typo in modulefile manpage --- doc/source/modulefile.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/modulefile.rst b/doc/source/modulefile.rst index 8834d416f..1fc10c9df 100644 --- a/doc/source/modulefile.rst +++ b/doc/source/modulefile.rst @@ -134,8 +134,8 @@ the *modulefile* is being loaded. **getenv** variable -Returns value of environment *variable*. If *variable* is not defined -*_UNDEFINED_* is returned. + Returns value of environment *variable*. If *variable* is not defined + *_UNDEFINED_* is returned. **append-path** [-d C|--delim C|--delim=C] [--duplicates] variable value... From 400c26bc197ca97e98bea80935c3f82d918178b8 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 1 Jul 2018 17:34:39 +0200 Subject: [PATCH 15/28] doc: state in modulefile(4) getenv should be pref. over ::env --- doc/source/modulefile.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/modulefile.rst b/doc/source/modulefile.rst index 1fc10c9df..a5ee18e6a 100644 --- a/doc/source/modulefile.rst +++ b/doc/source/modulefile.rst @@ -135,7 +135,8 @@ the *modulefile* is being loaded. **getenv** variable Returns value of environment *variable*. If *variable* is not defined - *_UNDEFINED_* is returned. + *_UNDEFINED_* is returned. **getenv** command should be preferred over Tcl + global variable **env** to query environment variables. **append-path** [-d C|--delim C|--delim=C] [--duplicates] variable value... From 9a203ef72ff5e2617f52ea3922f3fb01e5fd58af Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 1 Jul 2018 17:40:59 +0200 Subject: [PATCH 16/28] install: consider v4.1.x branch similar to master When it comes to define release number to build tarball. --- Makefile | 2 ++ configure | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8149fdadc..f6068cf76 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,8 @@ ifeq ($(GIT_CURRENT_TAG),$(GIT_CURRENT_DESC)) MODULES_BUILD := else ifeq ($(GIT_CURRENT_BRANCH),master) MODULES_BUILD := +$(subst $(GIT_CURRENT_TAG)-,,$(GIT_CURRENT_DESC)) +else ifeq ($(GIT_CURRENT_BRANCH),v4.1.x) +MODULES_BUILD := +$(subst $(GIT_CURRENT_TAG)-,,$(GIT_CURRENT_DESC)) else MODULES_BUILD := +$(GIT_CURRENT_BRANCH)$(subst $(GIT_CURRENT_TAG),,$(GIT_CURRENT_DESC)) endif diff --git a/configure b/configure index f65d00778..6df113e3e 100755 --- a/configure +++ b/configure @@ -389,7 +389,7 @@ if [ -d '.git' ]; then release=${gitcurtag#v} if [ "$gitcurtag" = "$gitcurdesc" ]; then build='' - elif [ "$gitcurbranch" = 'master' ]; then + elif [ "$gitcurbranch" = 'master' -o "$gitcurbranch" = 'v4.1.x' ]; then build="+${gitcurdesc#${gitcurtag}-}" else build="+${gitcurbranch}${gitcurdesc#${gitcurtag}}" From 19880ee9d194f9af8abd7308d50779f67eb4a4b6 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 13 Jul 2018 09:12:13 +0200 Subject: [PATCH 17/28] init: enable ERE on sed with '-E' argument rather '-r' When enabling Extended Regular Expression (ERE) on sed command, use the '-E' argument (rather '-r') for compatibility with OS X's and BSDs' sed. 'sed -E' is used in bash and zsh completion scripts. ERE are required to interpret alternation character '|'. Fixes #178 --- init/bash_completion.in | 2 +- init/zsh-functions/_module | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/init/bash_completion.in b/init/bash_completion.in index b11880614..a93381f4b 100644 --- a/init/bash_completion.in +++ b/init/bash_completion.in @@ -21,7 +21,7 @@ _module_savelist() { } _module_not_yet_loaded() { - _module_avail | sort | sed -r "\%^(${LOADEDMODULES//:/|})$%d" + _module_avail | sort | sed -E "\%^(${LOADEDMODULES//:/|})$%d" } _module_long_arg_list() { diff --git a/init/zsh-functions/_module b/init/zsh-functions/_module index 45042d10d..50718b127 100644 --- a/init/zsh-functions/_module +++ b/init/zsh-functions/_module @@ -25,7 +25,7 @@ _module_savelist() { } _module_not_yet_loaded() { - _module_avail | sort | sed -r "\%^(${LOADEDMODULES//:/|})$%d" + _module_avail | sort | sed -E "\%^(${LOADEDMODULES//:/|})$%d" } From 395b25a224e2d0e9cb45479afb8fcf87d52e08a4 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 13 Jul 2018 15:36:19 +0200 Subject: [PATCH 18/28] Handle default version sets on an hidden modulefile When looking for the default version of a given modulefile, if this default is set on an hidden modulefile, this hidden modulefile were not found as the initial modulefile search were not looking for hidden modulefiles. When this situation is now spotted, modulefile search is started again with inclusion of hidden files. Add a test for this situation in 20-locate/067-hidden. Fixes #177 --- modulecmd.tcl.in | 5 + testsuite/modulefiles/loc_rc010/.1.0 | 36 +++++ testsuite/modulefiles/loc_rc010/.modulerc | 28 ++++ testsuite/modulefiles/loc_rc010/2.0 | 36 +++++ testsuite/modules.20-locate/067-hidden.exp | 13 +- testsuite/modules.70-maint/130-aliases.exp | 2 + testsuite/modules.90-avail/070-full.exp | 167 +++++++++++---------- 7 files changed, 202 insertions(+), 85 deletions(-) create mode 100644 testsuite/modulefiles/loc_rc010/.1.0 create mode 100644 testsuite/modulefiles/loc_rc010/.modulerc create mode 100644 testsuite/modulefiles/loc_rc010/2.0 diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 91424e112..4780ada73 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -2713,6 +2713,11 @@ proc getPathToModule {mod {indir {}} {look_loaded "no"} {excdir {}}} { {directory} { # Move to default element in directory set mod "$mod/[lindex $mod_list($mod) 1]" + # restart search if default element is hidden and hidden + # elements were not searched + if {!$fetch_hidden && [isModuleHidden $mod]} { + return [getPathToModule $mod $indir] + } } {modulefile} { # If mod was a file in this path, return that file diff --git a/testsuite/modulefiles/loc_rc010/.1.0 b/testsuite/modulefiles/loc_rc010/.1.0 new file mode 100644 index 000000000..f2107393d --- /dev/null +++ b/testsuite/modulefiles/loc_rc010/.1.0 @@ -0,0 +1,36 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: loc_rc010/%M% +# Revision: %I% +# First Edition: 2018/07/13 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: ModulesHelp, ModulesTest, module-whatis, setenv +# Sub-Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# Test the correct location of hidden modules (modulefile with +# part of their name starting with a "dot") +# }C% +# +############################################################################## + +proc ModulesHelp {} { +} + +proc ModulesTest {} { + return 1 +} + +module-whatis "[module-info name]" +setenv testsuite "yes" diff --git a/testsuite/modulefiles/loc_rc010/.modulerc b/testsuite/modulefiles/loc_rc010/.modulerc new file mode 100644 index 000000000..f8f8e3c8e --- /dev/null +++ b/testsuite/modulefiles/loc_rc010/.modulerc @@ -0,0 +1,28 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: loc_rc010/%M% +# Revision: %I% +# First Edition: 2018/07/13 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: module-version +# Sub-Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# Test the correct location of hidden modules (modulefile with +# part of their name starting with a "dot") +# }C% +# +############################################################################## + +module-version ./.1.0 default diff --git a/testsuite/modulefiles/loc_rc010/2.0 b/testsuite/modulefiles/loc_rc010/2.0 new file mode 100644 index 000000000..f2107393d --- /dev/null +++ b/testsuite/modulefiles/loc_rc010/2.0 @@ -0,0 +1,36 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: loc_rc010/%M% +# Revision: %I% +# First Edition: 2018/07/13 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite modulefile +# Command: ModulesHelp, ModulesTest, module-whatis, setenv +# Sub-Command: +# +# Invocation: +# Result: %R{ +# }R% +# Comment: %C{ +# Test the correct location of hidden modules (modulefile with +# part of their name starting with a "dot") +# }C% +# +############################################################################## + +proc ModulesHelp {} { +} + +proc ModulesTest {} { + return 1 +} + +module-whatis "[module-info name]" +setenv testsuite "yes" diff --git a/testsuite/modules.20-locate/067-hidden.exp b/testsuite/modules.20-locate/067-hidden.exp index f2639c107..73c916e12 100644 --- a/testsuite/modules.20-locate/067-hidden.exp +++ b/testsuite/modules.20-locate/067-hidden.exp @@ -88,6 +88,15 @@ set modulefile_10 "$modpath/$module_10" set modulefilere_10 "$modpathre/$module_10" set modavail_10 "$module_10\\s+$datetime_re" +# hidden module is set default +set modsym_11 "loc_rc010" +set module_11 "$modsym_11/.1.0" +set modulefile_11 "$modpath/$module_11" +set modulefilere_11 "$modpathre/$module_11" +# does not appear on avail command, but appear on whatis and paths +set modavail_11 "$modsym_11/2.0\\s+$datetime_re" +set modwhatis_11 "\\s+$module_11: $module_11\n\\s+$modsym_11/2.0: $modsym_11/2.0" +set modpaths_11 [list $modulefile_11 $modpath/$modsym_11/2.0] set help_pre "$modlin\nModule Specific Help for " set help_post ":\n\n$modlin" @@ -105,7 +114,7 @@ set whatis_pre "$modlin $modpathre $modlin\n" # The tests # -for {set i 1} {$i <= 10} {incr i} { +for {set i 1} {$i <= 11} {incr i} { set modsym [set "modsym_${i}"] set module [set "module_${i}"] set modulefile [set "modulefile_${i}"] @@ -206,7 +215,7 @@ unset header_long unset avail_pre unset whatis_pre -for {set i 1} {$i <= 10} {incr i} { +for {set i 1} {$i <= 11} {incr i} { unset "modsym_${i}" unset "module_${i}" unset "modulefile_${i}" diff --git a/testsuite/modules.70-maint/130-aliases.exp b/testsuite/modules.70-maint/130-aliases.exp index acfb5bc67..ded4b6784 100644 --- a/testsuite/modules.70-maint/130-aliases.exp +++ b/testsuite/modules.70-maint/130-aliases.exp @@ -81,6 +81,7 @@ loc_rc4/default -> loc_rc4/2.0 loc_rc6/default -> loc_rc6/1.2 loc_rc6/new -> loc_rc6/1.2 loc_rc8/foo -> loc_rc8/.2.0 +loc_rc010/default -> loc_rc010/.1.0 loc_rcv1/default -> loc_rcv1/1.2 loc_rcv1/new -> loc_rcv1/1.2 loc_tr/bar -> loc_tr/3.0 @@ -205,6 +206,7 @@ loc_rc4/default -> loc_rc4/2.0 loc_rc6/default -> loc_rc6/1.2 loc_rc6/new -> loc_rc6/1.2 loc_rc8/foo -> loc_rc8/.2.0 +loc_rc010/default -> loc_rc010/.1.0 loc_rcv1/default -> loc_rcv1/1.2 loc_rcv1/new -> loc_rcv1/1.2 loc_tr/bar -> loc_tr/3.0 diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 03a04a5f0..0b7886771 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -41,89 +41,90 @@ set len [string length $modpath] set lrep [expr {($test_cols - $len - 2)/2}] set rrep [expr {$test_cols - $len - 2 - $lrep}] set ts_sh "[string repeat {-} $lrep] $modpath [string repeat {-} $rrep] -alias/1.0 info/shellsexp loc_sym/1.0 modbad/is-avail spread/4.0 -alias/2.0 info/specified(foo) loc_sym/alias1 modbad/is-loaded spread/5.0 -alias/3.0 info/type loc_sym/alias2 modbad/is-saved spread/6.0 -append/0.1 info/user loc_sym/alias3 modbad/is-used spread/7.0 -append/0.2 info/userexp loc_sym/alias4 modbad/path spread/8.0 -append/0.3 inforc/1.0 loc_sym/alias5 modbad/paths spreadrc/dir1/1.0 -append/0.4 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/prepend-path spreadrc/dir2/1.0 -append/0.5 inforc/foo(@) loc_sym/alias7 modbad/remove-path spreadrc/dir3/1.0 -append/1.0 load/00 loc_sym/alias8 module/2.0 spreadrc/dir4/1.0 -append/1.1 load/10 loc_sym/alias9 module/bad spreadrc/dir5/1.0 -append/1.3 load/11 loc_sym/alias10 module/empty spreadrc/dir6/1.0 -append/1.4 load/12 loc_sym/alias11 module/err spreadrc/dir7/1.0 -append/1.5 load/13 loc_sym/exec1 module/lbad spreadrc/dir8/1.0 -append/1.6 load/14 loc_sym/exec2 module/lerr symlink/0.9 -append/1.7 load/15 loc_sym/exec3 module/lunk symlink/1(@) -append/2.0 load/16 loc_sym/getvers1 module/meta symlink/1.2(default:new) -append/2.1 load/17 loc_sym/getvers2 module/relpath symlink/bar(@) -append/2.2 load/18 loc_sym/getvers3 module/unk symlink2/1.0 -append/2.3 load/19 loc_sym/getvers4 modvar/modfile symlink2/2.0 -append/2.4 load/20 loc_sym/getvers5 modvar/submodfile system/1.0 -append/4.0 load/21 loc_sym/getvers6 prepend/0.1 system/2.0 -append/4.1 load/22 loc_sym/getvers7 prepend/0.2 test/1.0 -append/5.0 load/23 loc_sym/getvers8 prepend/0.3 test/1.2 -append/6.0 load/24 loc_sym/getvers9 prepend/0.4 test/2.0 -averssort/1(@) load/25 loc_sym/getvers10 prepend/0.5 tr2_loc(trreg) -averssort/1.2.4(@) load/26 loc_sym/versinf1 prepend/1.0 tr2_loc/al1(tr2unstable:@) -averssort/1.10(@) load/27 loc_sym/versinf2 prepend/1.1 tr2_loc/al2(tr2bar:@) -bad/after(good) load/28 loc_sym/versinf3 prepend/1.3 tr2_loc/al3(default:tr2exp:trreg:@) -bad/before load/29 loc_sym/versinf4 prepend/1.4 tr2_loc/al4(@) -bad2/body load/30 loc_sym/versinf5 prepend/1.5 tr2_loc/al5(default:trreg:@) -bad2/proc load/all(default) loc_sym/versinf6 prepend/1.6 tr_loc/al1(tr2unstable:trunstable:@) -break/1.0 loc_def/default loc_sym/versinf7 prepend/1.7 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) -break/2.0 loc_def/truedef loc_sym/version1 prepend/1.8 tr_loc/al3(trexp:@) -break/3.0 loc_dv1/1.0 loc_sym/version2 prepend/1.9 tr_loc/al4(@) -break/4.0 loc_dv1/2.0 loc_sym/version3 prepend/2.0 tr_loc/al5(@) -break/5.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.1 trace/all_off -break/6.0 loc_dv2/2.0 loc_sym/version5 prepend/2.2 trace/all_on -chdir/1.0 loc_dv3/1.0 loc_sym/version6 prepend/2.3 uname/cache -chdir/2.0 loc_dv3/2.0 loc_sym/version7 prepend/2.4 uname/domain -chdir/3.0 loc_dv4/1.0 loc_sym/version8 prepend/3.0 uname/machine -chdir/4.0 loc_dv6/1.0 loc_sym/version9 prepend/3.1 uname/nodename -coll/a loc_dv6/2.0/1.0 loc_sym/version10 prereq/full uname/release -coll/b loc_dv7/1.0 loc_sym/version11 prereq/fullpath uname/sysname -coll/c loc_dv7/2.0(default) loc_sym/version12 prereq/module uname/unk -coll/d loc_dv7/2.0/1.0 loc_sym/version13 prereq/orlist uname/version -conflict/full loc_dv7/3.0 loc_sym/version14 prereq/relpath unsetenv/0.8 -conflict/fullpath loc_dv8/1.0 loc_sym/version15 puts/1 unsetenv/0.9 -conflict/module loc_dv8/2.0 loc_sym/version16 puts/2 unsetenv/1.0 -conflict/relpath loc_dv9/1.0(default) loc_sym/version17 puts/3 use/1.0(default) -continue/1.0 loc_dv9/2.0 loc_sym/version18 puts/4 use/2.0 -continue/2.0 loc_dvv1/1.0(default) loc_sym/version19 puts/5 use/2.1 -continue/3.0 loc_dvv1/2.0 loc_sym/version20 puts/6 use/2.2 -continue/4.0 loc_fq/1.0 loc_sym/version21 puts/7 use/3.0 -continue/5.0 loc_rc1/1.0(foo) loc_sym/version22 puts/8 use/3.1 -continue/6.0 loc_rc1/2.0 loc_sym/version23 recurs/modA use/3.2 -dirmodalias(@) loc_rc2/1.0(bar:blah:foo) loc_sym/version24 recurs/modB use/4.0 -dirmodalias/1.0 loc_rc2/2.0 loc_sym/version25 remove/0.3 use/4.1 -dirmodvirt loc_rc3/1.0(default) loc_sym/version26 remove/0.4 user/adv -dirmodvirt/1.0 loc_rc3/2.0(cur:stable) loc_tr(reg) remove/0.5 user/advanced -empty/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.0 user/exp -eschars/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.3 user/expert -exit/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.4 user/nov -exit/2.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.5 user/novice -exit/3.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.6 user/undef -exit/4.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/1.7 verbose/msg -getenv/1.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.0 verbose/off -help/2.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.3 verbose/on -info/command loc_rc6/1.2(default:new) loc_virt1/2.0 remove/2.4 verbose/undef -info/commandexp loc_rc6/bar(@) loc_virt1/3.0 remove/3.0 versions/1.1 -info/isavail loc_rc7/0.9 loc_virt1/4.0 remove/3.1 versions/1.2 -info/isloaded loc_rc7/1(@) loc_virt2/1.0 remove/4.0 versions/1.3 -info/issaved loc_rc7/1.2 loc_virt2/2.0 remove/4.1 verssort/1 -info/isused loc_rc7/bar(@) log/badfac remove/4.2 verssort/1.2.1 -info/loaded loc_rc8/0.9(@) log/err_both_1 setenv/0.6 verssort/1.2.4 -info/mode1 loc_rc8/1.0 log/err_both_2 setenv/0.8 verssort/1.8-2015-12-01 -info/mode2 loc_rcv1/1(@) log/err_file setenv/1.0 verssort/1.8-2016-02-01 -info/mode3 loc_rcv1/1.1 log/err_syslog source/0.9 verssort/1.10 -info/mode4 loc_rcv1/1.2(default:new) modbad/append-path source/1.0 whatis/lines -info/mode5 loc_rcv1/2.0 modbad/autoinit source/1.1 whatis/multiple -info/mode6 loc_rcv1/bar(@) modbad/empty source/1.2 whatis/none -info/name loc_rcv2/1.2 modbad/foo spread/1.0 whatis/single -info/others loc_rcv2/1.5 modbad/help spread/2.0 whatis/string -info/shells loc_rcv2/2.0 modbad/info-loaded spread/3.0 x-resource/1 " +alias/1.0 info/specified(foo) loc_sym/alias1 modbad/is-saved spread/7.0 +alias/2.0 info/type loc_sym/alias2 modbad/is-used spread/8.0 +alias/3.0 info/user loc_sym/alias3 modbad/path spreadrc/dir1/1.0 +append/0.1 info/userexp loc_sym/alias4 modbad/paths spreadrc/dir2/1.0 +append/0.2 inforc/1.0 loc_sym/alias5 modbad/prepend-path spreadrc/dir3/1.0 +append/0.3 inforc/2.0(avail:bar:default) loc_sym/alias6 modbad/remove-path spreadrc/dir4/1.0 +append/0.4 inforc/foo(@) loc_sym/alias7 module/2.0 spreadrc/dir5/1.0 +append/0.5 load/00 loc_sym/alias8 module/bad spreadrc/dir6/1.0 +append/1.0 load/10 loc_sym/alias9 module/empty spreadrc/dir7/1.0 +append/1.1 load/11 loc_sym/alias10 module/err spreadrc/dir8/1.0 +append/1.3 load/12 loc_sym/alias11 module/lbad symlink/0.9 +append/1.4 load/13 loc_sym/exec1 module/lerr symlink/1(@) +append/1.5 load/14 loc_sym/exec2 module/lunk symlink/1.2(default:new) +append/1.6 load/15 loc_sym/exec3 module/meta symlink/bar(@) +append/1.7 load/16 loc_sym/getvers1 module/relpath symlink2/1.0 +append/2.0 load/17 loc_sym/getvers2 module/unk symlink2/2.0 +append/2.1 load/18 loc_sym/getvers3 modvar/modfile system/1.0 +append/2.2 load/19 loc_sym/getvers4 modvar/submodfile system/2.0 +append/2.3 load/20 loc_sym/getvers5 prepend/0.1 test/1.0 +append/2.4 load/21 loc_sym/getvers6 prepend/0.2 test/1.2 +append/4.0 load/22 loc_sym/getvers7 prepend/0.3 test/2.0 +append/4.1 load/23 loc_sym/getvers8 prepend/0.4 tr2_loc(trreg) +append/5.0 load/24 loc_sym/getvers9 prepend/0.5 tr2_loc/al1(tr2unstable:@) +append/6.0 load/25 loc_sym/getvers10 prepend/1.0 tr2_loc/al2(tr2bar:@) +averssort/1(@) load/26 loc_sym/versinf1 prepend/1.1 tr2_loc/al3(default:tr2exp:trreg:@) +averssort/1.2.4(@) load/27 loc_sym/versinf2 prepend/1.3 tr2_loc/al4(@) +averssort/1.10(@) load/28 loc_sym/versinf3 prepend/1.4 tr2_loc/al5(default:trreg:@) +bad/after(good) load/29 loc_sym/versinf4 prepend/1.5 tr_loc/al1(tr2unstable:trunstable:@) +bad/before load/30 loc_sym/versinf5 prepend/1.6 tr_loc/al2(default:tr2bar:tr2exp:trbar:trreg:@) +bad2/body load/all(default) loc_sym/versinf6 prepend/1.7 tr_loc/al3(trexp:@) +bad2/proc loc_def/default loc_sym/versinf7 prepend/1.8 tr_loc/al4(@) +break/1.0 loc_def/truedef loc_sym/version1 prepend/1.9 tr_loc/al5(@) +break/2.0 loc_dv1/1.0 loc_sym/version2 prepend/2.0 trace/all_off +break/3.0 loc_dv1/2.0 loc_sym/version3 prepend/2.1 trace/all_on +break/4.0 loc_dv2/1.0(default) loc_sym/version4 prepend/2.2 uname/cache +break/5.0 loc_dv2/2.0 loc_sym/version5 prepend/2.3 uname/domain +break/6.0 loc_dv3/1.0 loc_sym/version6 prepend/2.4 uname/machine +chdir/1.0 loc_dv3/2.0 loc_sym/version7 prepend/3.0 uname/nodename +chdir/2.0 loc_dv4/1.0 loc_sym/version8 prepend/3.1 uname/release +chdir/3.0 loc_dv6/1.0 loc_sym/version9 prereq/full uname/sysname +chdir/4.0 loc_dv6/2.0/1.0 loc_sym/version10 prereq/fullpath uname/unk +coll/a loc_dv7/1.0 loc_sym/version11 prereq/module uname/version +coll/b loc_dv7/2.0(default) loc_sym/version12 prereq/orlist unsetenv/0.8 +coll/c loc_dv7/2.0/1.0 loc_sym/version13 prereq/relpath unsetenv/0.9 +coll/d loc_dv7/3.0 loc_sym/version14 puts/1 unsetenv/1.0 +conflict/full loc_dv8/1.0 loc_sym/version15 puts/2 use/1.0(default) +conflict/fullpath loc_dv8/2.0 loc_sym/version16 puts/3 use/2.0 +conflict/module loc_dv9/1.0(default) loc_sym/version17 puts/4 use/2.1 +conflict/relpath loc_dv9/2.0 loc_sym/version18 puts/5 use/2.2 +continue/1.0 loc_dvv1/1.0(default) loc_sym/version19 puts/6 use/3.0 +continue/2.0 loc_dvv1/2.0 loc_sym/version20 puts/7 use/3.1 +continue/3.0 loc_fq/1.0 loc_sym/version21 puts/8 use/3.2 +continue/4.0 loc_rc1/1.0(foo) loc_sym/version22 recurs/modA use/4.0 +continue/5.0 loc_rc1/2.0 loc_sym/version23 recurs/modB use/4.1 +continue/6.0 loc_rc2/1.0(bar:blah:foo) loc_sym/version24 remove/0.3 user/adv +dirmodalias(@) loc_rc2/2.0 loc_sym/version25 remove/0.4 user/advanced +dirmodalias/1.0 loc_rc3/1.0(default) loc_sym/version26 remove/0.5 user/exp +dirmodvirt loc_rc3/2.0(cur:stable) loc_tr(reg) remove/1.0 user/expert +dirmodvirt/1.0 loc_rc3/3.0(chk:exp:new:test) loc_tr/1.0(cur:stable) remove/1.3 user/nov +empty/1.0 loc_rc4/1.0 loc_tr/2.0(next:tr2unstable:trunstable:unstable) remove/1.4 user/novice +eschars/1.0 loc_rc4/2.0(default) loc_tr/3.0(bar:default:exp:foo:reg:tr2bar:tr2exp:trbar:trexp:trreg) remove/1.5 user/undef +exit/1.0 loc_rc4/3.0 loc_tr/al1(unstable:@) remove/1.6 verbose/msg +exit/2.0 loc_rc5/1.0 loc_tr/al2(bar:default:exp:reg:trexp:@) remove/1.7 verbose/off +exit/3.0 loc_rc5/2.0 loc_tr/al3(default:exp:reg:@) remove/2.0 verbose/on +exit/4.0 loc_rc6/0.9 loc_tr/al4(default:reg:@) remove/2.3 verbose/undef +getenv/1.0 loc_rc6/1(@) loc_virt1/1.0 remove/2.4 versions/1.1 +help/2.0 loc_rc6/1.2(default:new) loc_virt1/2.0 remove/3.0 versions/1.2 +info/command loc_rc6/bar(@) loc_virt1/3.0 remove/3.1 versions/1.3 +info/commandexp loc_rc7/0.9 loc_virt1/4.0 remove/4.0 verssort/1 +info/isavail loc_rc7/1(@) loc_virt2/1.0 remove/4.1 verssort/1.2.1 +info/isloaded loc_rc7/1.2 loc_virt2/2.0 remove/4.2 verssort/1.2.4 +info/issaved loc_rc7/bar(@) log/badfac setenv/0.6 verssort/1.8-2015-12-01 +info/isused loc_rc8/0.9(@) log/err_both_1 setenv/0.8 verssort/1.8-2016-02-01 +info/loaded loc_rc8/1.0 log/err_both_2 setenv/1.0 verssort/1.10 +info/mode1 loc_rc010/2.0 log/err_file source/0.9 whatis/lines +info/mode2 loc_rcv1/1(@) log/err_syslog source/1.0 whatis/multiple +info/mode3 loc_rcv1/1.1 modbad/append-path source/1.1 whatis/none +info/mode4 loc_rcv1/1.2(default:new) modbad/autoinit source/1.2 whatis/single +info/mode5 loc_rcv1/2.0 modbad/empty spread/1.0 whatis/string +info/mode6 loc_rcv1/bar(@) modbad/foo spread/2.0 x-resource/1 +info/name loc_rcv2/1.2 modbad/help spread/3.0 +info/others loc_rcv2/1.5 modbad/info-loaded spread/4.0 +info/shells loc_rcv2/2.0 modbad/is-avail spread/5.0 +info/shellsexp loc_sym/1.0 modbad/is-loaded spread/6.0 " set ts_sh_small "- $modpath.deep - dir2/1.0(d1) From 7bbf602f60801ebde20c87c151e0604a136d4ce9 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 13 Jul 2018 17:57:10 +0200 Subject: [PATCH 19/28] init: fix ksh script for ksh88 compatibility Fix a ksh88 incompatible assignment and use '.' rather 'source' to source external script. Fixes #159 --- init/ksh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/ksh.in b/init/ksh.in index f0db26533..df59ecb99 100644 --- a/init/ksh.in +++ b/init/ksh.in @@ -75,7 +75,7 @@ unset _mlre _mlv _mlrv @compatversion@ # switch version only if command found @compatversion@ if [ $swfound -eq 0 ]; then @compatversion@ echo "Switching to Modules $swname version" -@compatversion@ source @initdir@/ksh +@compatversion@ . @initdir@/ksh @compatversion@ else @compatversion@ echo "Cannot switch to Modules $swname version, command not found" @compatversion@ return 1 @@ -93,7 +93,7 @@ BASH_ENV=@initdir@/bash; export BASH_ENV # set for 'zsh' shell when it starts. _mlinstr=":$FPATH:" if [ "${_mlinstr#*:@initdir@/ksh-functions:}" = "$_mlinstr" ]; then - FPATH+="${FPATH:+:}@initdir@/ksh-functions"; export FPATH + FPATH=$FPATH${FPATH:+:}@initdir@/ksh-functions; export FPATH fi @setbinpath@_mlinstr=":$PATH:" From 65b21fc19a0bc6bf9e2f000238d1334a1a429704 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Fri, 13 Jul 2018 22:37:42 +0200 Subject: [PATCH 20/28] install: use sed rather grep and cut Use sed command rather a combination of grep and cut in 'configure' and 'Makefile' scripts. As a result grep and cut commands are not required anymore to install new Modules releases. However, grep is still required to install compatibility version. Big thanks to Michael Sternberg (@mgsternberg) for crafting the right sed commands to achieve a more efficient installation process. Fixes #175 --- INSTALL.rst | 3 +-- Makefile | 4 ++-- configure | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/INSTALL.rst b/INSTALL.rst index 4b575a9b6..f7cdb2789 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -23,8 +23,6 @@ the tools to be found on your system: * bash * make * sed -* grep -* cut * runtest When also installing the bundled compatibility version of Modules (enabled @@ -33,6 +31,7 @@ by default), these additional tools are needed: * autoconf * automake * autopoint +* grep * gcc * tcl-devel >= 8.4 diff --git a/Makefile b/Makefile index f6068cf76..55dcf2581 100644 --- a/Makefile +++ b/Makefile @@ -71,8 +71,8 @@ MODULES_RELEASE_SUFFIX := else MODULES_RELEASE_SUFFIX := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_RELEASE)) endif -MODULES_LAST_RPM_VERSREL := $(shell grep -A 1 '%changelog' \ - contrib/rpm/environment-modules.spec.in | grep '^* ' | grep -Eo '\S+$$') +MODULES_LAST_RPM_VERSREL := $(shell sed -n '/^%changelog/ {n;s/^\*.* - //p;q;}' \ + contrib/rpm/environment-modules.spec.in) MODULES_LAST_RPM_RELEASE := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_LAST_RPM_VERSREL)) ifneq ($(MODULES_RELEASE_SUFFIX),) diff --git a/configure b/configure index 6df113e3e..7bd80d29e 100755 --- a/configure +++ b/configure @@ -328,8 +328,6 @@ case "$kernelname" in esac check_requirement $make check_requirement sed -check_requirement grep -check_requirement cut check_requirement runtest "Install \`dejagnu' if you want to run the \ testsuite" check_requirement manpath 'Will rely on MANPATH to get enabled man directories' @@ -396,8 +394,8 @@ if [ -d '.git' ]; then fi # elsewhere fetch modules version from version.inc file elif [ -r ${progdir}/version.inc ]; then - release=$(grep '^MODULES_RELEASE ' ${progdir}/version.inc | cut -d ' ' -f 3) - build=$(grep '^MODULES_BUILD ' ${progdir}/version.inc | cut -d ' ' -f 3) + release=$(sed -n '/^MODULES_RELEASE/{s/.*= //p;q;}' ${progdir}/version.inc) + build=$(sed -n '/^MODULES_BUILD/{s/.*= //p;q;}' ${progdir}/version.inc) fi VERSION=$release$build From b3cf67534e5f673ce31c42445a8130f28754e92c Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 15 Jul 2018 10:43:10 +0200 Subject: [PATCH 21/28] install: simplify RPM release number generation Just append current build number to previous RPM release number, rather making a complex and too much specific computation. Thanks to Michael Sternberg (@mgsternberg) for challenging the way this numbering generation worked. Fixes #175 --- Makefile | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 55dcf2581..c529b1d78 100644 --- a/Makefile +++ b/Makefile @@ -64,40 +64,11 @@ MODULES_BUILD := +$(GIT_CURRENT_BRANCH)$(subst $(GIT_CURRENT_TAG),,$(GIT_CURRENT endif # determine RPM release -# retrieve all parts of the release number and increase minor release number -MODULES_RELEASE_BASE := $(firstword $(subst -, ,$(MODULES_RELEASE))) -ifeq ($(MODULES_RELEASE),$(MODULES_RELEASE_BASE)) -MODULES_RELEASE_SUFFIX := -else -MODULES_RELEASE_SUFFIX := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_RELEASE)) -endif +# use last release if we currently sat on tag, append build number to it elsewhere MODULES_LAST_RPM_VERSREL := $(shell sed -n '/^%changelog/ {n;s/^\*.* - //p;q;}' \ contrib/rpm/environment-modules.spec.in) - -MODULES_LAST_RPM_RELEASE := $(subst $(MODULES_RELEASE_BASE)-,,$(MODULES_LAST_RPM_VERSREL)) -ifneq ($(MODULES_RELEASE_SUFFIX),) -MODULES_LAST_RPM_RELEASE := $(subst .$(MODULES_RELEASE_SUFFIX),,$(MODULES_LAST_RPM_RELEASE)) -endif - -# use last release if we currently sat on tag -ifeq ($(GIT_CURRENT_TAG),$(GIT_CURRENT_DESC)) -MODULES_RPM_RELEASE := $(MODULES_LAST_RPM_RELEASE) -else -MODULES_LAST_RPM_RELEASE_P1 := $(firstword $(subst ., ,$(MODULES_LAST_RPM_RELEASE))) -MODULES_LAST_RPM_RELEASE_P2 := $(subst $(MODULES_LAST_RPM_RELEASE_P1).,,$(MODULES_LAST_RPM_RELEASE)) - -ifeq ($(MODULES_LAST_RPM_RELEASE_P2),) -MODULES_RPM_RELEASE_P2 := 1 -else -MODULES_RPM_RELEASE_P2 := $(shell echo $$(($(MODULES_LAST_RPM_RELEASE_P2)+1))) -endif - -MODULES_RPM_RELEASE := $(MODULES_LAST_RPM_RELEASE_P1).$(MODULES_RPM_RELEASE_P2) -ifneq ($(MODULES_RELEASE_SUFFIX),) -MODULES_RPM_RELEASE := $(MODULES_RPM_RELEASE).$(MODULES_RELEASE_SUFFIX) -endif -MODULES_RPM_RELEASE := $(MODULES_RPM_RELEASE)$(subst -,.,$(MODULES_BUILD)) -endif +MODULES_LAST_RPM_RELEASE := $(lastword $(subst -, ,$(MODULES_LAST_RPM_VERSREL))) +MODULES_RPM_RELEASE := $(MODULES_LAST_RPM_RELEASE)$(subst +,.,$(subst -,.,$(MODULES_BUILD))) else # source version definitions shared across the Makefiles of this project From 2a3d57c6413ec778673c732696220b4f09b03bbc Mon Sep 17 00:00:00 2001 From: Jan Synacek Date: Thu, 16 Aug 2018 12:11:02 +0200 Subject: [PATCH 22/28] contrib: createmodule.py: fix tab indentation --- contrib/scripts/createmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scripts/createmodule.py b/contrib/scripts/createmodule.py index 3c778c127..422951909 100755 --- a/contrib/scripts/createmodule.py +++ b/contrib/scripts/createmodule.py @@ -105,7 +105,7 @@ def normpaths(paths): continue #Working directory change if key == 'PWD': - chdir=os.path.normpath(env2[key]) + chdir=os.path.normpath(env2[key]) pathnames.append(chdir) del env2[key] continue From 70ba53eff872b60c0e8b63cfcbf58aadd5a49aff Mon Sep 17 00:00:00 2001 From: Jan Synacek Date: Thu, 16 Aug 2018 12:44:03 +0200 Subject: [PATCH 23/28] contrib: createmodule.py: open pipes in text mode Otherwise, pipes are opened in binary mode and there are type errors further down the code. --- contrib/scripts/createmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scripts/createmodule.py b/contrib/scripts/createmodule.py index 422951909..f15b3ce62 100755 --- a/contrib/scripts/createmodule.py +++ b/contrib/scripts/createmodule.py @@ -39,7 +39,7 @@ # Return environment after a command def getenv(cmd = ':'): env = {} - p = Popen(cmd + ";env", shell=True, stdout=PIPE, stderr=PIPE) + p = Popen(cmd + ";env", shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode != 0: print("EROR: Could not execute initscript:") From 8e803ac0d0dd0b29c08ea59855bd214aa8f054ef Mon Sep 17 00:00:00 2001 From: Jan Synacek Date: Thu, 16 Aug 2018 12:48:39 +0200 Subject: [PATCH 24/28] contrib: createmodule.py: fix typo --- contrib/scripts/createmodule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scripts/createmodule.py b/contrib/scripts/createmodule.py index f15b3ce62..000728799 100755 --- a/contrib/scripts/createmodule.py +++ b/contrib/scripts/createmodule.py @@ -42,7 +42,7 @@ def getenv(cmd = ':'): p = Popen(cmd + ";env", shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() if p.returncode != 0: - print("EROR: Could not execute initscript:") + print("ERROR: Could not execute initscript:") print("%s returned exit code %d" % (cmd, p.returncode)) print(stderr) exit(1) From f67cd1120e686e43b8c6edc09c64c3b3b2326d97 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 2 Aug 2018 08:34:47 +0200 Subject: [PATCH 25/28] travis: help compat configure to locate tclConfig.sh on osx --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f60771fb7..8f39b0ce2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -237,7 +237,8 @@ matrix: - env: CONFIGURE_OPTS='--prefix=/tmp/modules --disable-compat-version' MAKE_TESTCOVERAGE='y' os: osx - - env: CONFIGURE_OPTS='--prefix=/tmp/modules --enable-compat-version --with-loadedmodules=null:dot' + # need to specify where to find tclConfig.sh on newer xcode release + - env: CONFIGURE_OPTS='--prefix=/tmp/modules --enable-compat-version --with-loadedmodules=null:dot --with-tcl=/System/Library/Frameworks/Tcl.framework/Versions/8.5' os: osx From 6f406fa5730429878d28dffb2c0bb9f4cd04977d Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 19 Aug 2018 20:33:04 +0200 Subject: [PATCH 26/28] cookbook: add 'top-priority-values' recipe --- .../top-priority-values/modulefiles/bar/1 | 9 ++ .../top-priority-values/modulefiles/foo/1 | 9 ++ .../top-priority-values/siteconfig.tcl | 103 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 contrib/cookbook/top-priority-values/modulefiles/bar/1 create mode 100644 contrib/cookbook/top-priority-values/modulefiles/foo/1 create mode 100644 contrib/cookbook/top-priority-values/siteconfig.tcl diff --git a/contrib/cookbook/top-priority-values/modulefiles/bar/1 b/contrib/cookbook/top-priority-values/modulefiles/bar/1 new file mode 100644 index 000000000..09776f4ec --- /dev/null +++ b/contrib/cookbook/top-priority-values/modulefiles/bar/1 @@ -0,0 +1,9 @@ +#%Module +# define a regular value for variable +setenv TESTVAR value + +# prepend a regular value to a path-like variable +prepend-path TESTPATH prevalue + +# append a regular value to a path-like variable +append-path TESTPATH postvalue diff --git a/contrib/cookbook/top-priority-values/modulefiles/foo/1 b/contrib/cookbook/top-priority-values/modulefiles/foo/1 new file mode 100644 index 000000000..2e2a309ff --- /dev/null +++ b/contrib/cookbook/top-priority-values/modulefiles/foo/1 @@ -0,0 +1,9 @@ +#%Module +# define a value for variable holding top priority (not overwritten by non-top priority value) +setenv --top TESTVAR topvalue + +# prepend a value to a path-like variable, value that stays first position +prepend-path --top TESTPATH topprevalue + +# append a value to a path-like variable, value that stays last position +append-path --top TESTPATH toppostvalue diff --git a/contrib/cookbook/top-priority-values/siteconfig.tcl b/contrib/cookbook/top-priority-values/siteconfig.tcl new file mode 100644 index 000000000..f68d3f48e --- /dev/null +++ b/contrib/cookbook/top-priority-values/siteconfig.tcl @@ -0,0 +1,103 @@ +# +# siteconfig.tcl - Site specific configuration introducing a '--top' argument +# for the setenv, append-path and prepend-path modulefile commands. '--top' +# argument enables a value set with this flag on to hold top priority and +# thus cannot be altered unless by another top priority value. For +# 'append-path' command, '--top' ensure value will stay at last position in +# path-like variable. Same goes for 'prepend-path' where '--top' ensure +# first position in path-like variable. +# +# Author: Xavier Delaruelle +# Compatibility: Modules v4.1 +# +# Installation: put this file in the 'etc' directory of your Modules +# installation. Refer to the "Modulecmd startup" section in the +# module(1) man page to get this location. + +# override 'setenv' procedure to add a '--top' optional argument +rename ::setenv ::__setenv +proc setenv {args} { + set topPriority 0 + set errArgMsg "wrong # args: should be \"setenv ?--top? var val\"" + switch -- [llength $args] { + {3} { + if {[lindex $args 0] eq "--top"} { + set topPriority 1 + } else { + error $errArgMsg + } + set var [lindex $args 1] + set val [lindex $args 2] + } + {2} { + set var [lindex $args 0] + set val [lindex $args 1] + } + default { + error $errArgMsg + } + } + + if {$topPriority} { + # define an helper variable to know a top-priority value has been set + if {[currentMode] ne "display"} { + __setenv MODULES_PRIORITY_$var $val + } + __setenv $var $val + # set non-priority value only if no top priority value already set + } elseif {![info exists ::env(MODULES_PRIORITY_$var)]} { + __setenv $var $val + } +} + +# override 'add-path' procedure to add a '--top' optional argument, which +# will benefit to the 'append-path' and 'prepend-path' modulefile commands +rename ::add-path ::__add-path +proc add-path {pos args} { + set keep_top_priority 0 + set arglist [lsearch -all -inline -not -exact $args "--top"] + lassign [eval parsePathCommandArgs "add-path" $arglist] separator\ + allow_dup idx_val var path_list + + # top priority asked + if {[llength $arglist] != [llength $args]} { + # record this top priority value in an helper variable + __setenv MODULES_PRIORITY_${pos}_$var $path_list + } elseif {[info exists ::env(MODULES_PRIORITY_${pos}_$var)]} { + set keep_top_priority 1 + } + + # ensure top-priority value keeps first or last position by unloading it + # priority new value addition, then restoring it + if {$keep_top_priority} { + eval __unload-path $var $::env(MODULES_PRIORITY_${pos}_$var) + } + + eval __add-path $pos $arglist + + if {$keep_top_priority} { + eval __add-path $pos $var $::env(MODULES_PRIORITY_${pos}_$var) + } +} + +rename ::unload-path ::__unload-path +proc unload-path {args} { + set arglist [lsearch -all -inline -not -exact $args "--top"] + lassign [eval parsePathCommandArgs "unload-path" $arglist] separator\ + allow_dup idx_val var path_list + + if {[llength $arglist] != [llength $args]} { + # wipe priority helper variable when unloading top priority value + switch -- [lindex [info level -1] 0] { + {append-path} { set pos "append" } + {prepend-path} { set pos "prepend" } + } + if {[info exists pos]} { + __setenv MODULES_PRIORITY_${pos}_$var $path_list + } + } + + eval __unload-path $arglist +} + +# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: From 9deb6fda28df53ce93ae3f625d67133b28a0f9e3 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Mon, 20 Aug 2018 07:13:13 +0200 Subject: [PATCH 27/28] ModulesVersion can only refer to modfile in same dir Clarify modulefile man page and .version modulerc interpretation about ModulesVersion variable which can only refer to modulefile located in the same directory than where this .version modulerc file is located. Report error if a nested ModulesVersion value is detected. This value is ignored. Add tests in 80-deep suite on that change. Clarifies RH#979787 [1] Fixes #176 [1] https://bugzilla.redhat.com/show_bug.cgi?id=979787 --- doc/source/modulefile.rst | 5 +-- modulecmd.tcl.in | 9 ++++-- .../modulefiles.deep/badmodvers/.version | 3 ++ .../modulefiles.deep/badmodvers/dir1/2.0 | 3 ++ testsuite/modulefiles.deep/badmodvers/foo | 3 ++ testsuite/modules.80-deep/010-init_ts.exp | 6 ++++ testsuite/modules.80-deep/020-load.exp | 13 ++++++++ testsuite/modules.80-deep/021-unload.exp | 17 ++++++++++ testsuite/modules.80-deep/030-display.exp | 6 ++++ testsuite/modules.80-deep/050-whatis.exp | 3 ++ testsuite/modules.80-deep/999-cleanup.exp | 6 ++++ testsuite/modules.90-avail/070-full.exp | 32 +++++++++++-------- 12 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 testsuite/modulefiles.deep/badmodvers/.version create mode 100644 testsuite/modulefiles.deep/badmodvers/dir1/2.0 create mode 100644 testsuite/modulefiles.deep/badmodvers/foo diff --git a/doc/source/modulefile.rst b/doc/source/modulefile.rst index a5ee18e6a..8f6cd40c1 100644 --- a/doc/source/modulefile.rst +++ b/doc/source/modulefile.rst @@ -504,8 +504,9 @@ will be sourced. Otherwise the file *.version* is looked up in the directory. If the *.version* file exists, it is opened and interpreted as Tcl code and takes precedence over a *.modulerc* file in the same directory. If the Tcl variable **ModulesVersion** is set by the *.version* file, **modulecmd.tcl** -will use the name as if it specifies a *modulefile* in the directory. This -will become the default *modulefile* in this case. +will use the name as if it specifies a *modulefile* in this directory. This +will become the default *modulefile* in this case. **ModulesVersion** cannot +refer to a *modulefile* located in a different directory. If **ModulesVersion** is a directory, the search begins anew down that directory. If the name does not match any files located in the current diff --git a/modulecmd.tcl.in b/modulecmd.tcl.in index 4780ada73..d33f99bd7 100755 --- a/modulecmd.tcl.in +++ b/modulecmd.tcl.in @@ -710,8 +710,13 @@ proc execute-modulerc {modfile} { # default version set via ModulesVersion variable in .version file # override previously defined default version for modname if {[file tail $modfile] eq ".version" && $::ModulesVersion ne ""} { - setModuleResolution "$modname/default" $modname/$::ModulesVersion\ - "default" + # ModulesVersion should target an element in current directory + if {[string first "/" $::ModulesVersion] == -1} { + setModuleResolution "$modname/default" $modname/$::ModulesVersion\ + "default" + } else { + reportError "Invalid ModulesVersion '$::ModulesVersion' defined" + } } # Keep track of rc files we already sourced so we don't run them again diff --git a/testsuite/modulefiles.deep/badmodvers/.version b/testsuite/modulefiles.deep/badmodvers/.version new file mode 100644 index 000000000..f8dc17800 --- /dev/null +++ b/testsuite/modulefiles.deep/badmodvers/.version @@ -0,0 +1,3 @@ +#%Module1.0 +set ModulesVersion "dir1/2.0" + diff --git a/testsuite/modulefiles.deep/badmodvers/dir1/2.0 b/testsuite/modulefiles.deep/badmodvers/dir1/2.0 new file mode 100644 index 000000000..3956ec6f1 --- /dev/null +++ b/testsuite/modulefiles.deep/badmodvers/dir1/2.0 @@ -0,0 +1,3 @@ +#%Module1.0 +module-whatis "badmodvers/dir1/2.0" + diff --git a/testsuite/modulefiles.deep/badmodvers/foo b/testsuite/modulefiles.deep/badmodvers/foo new file mode 100644 index 000000000..bd108100f --- /dev/null +++ b/testsuite/modulefiles.deep/badmodvers/foo @@ -0,0 +1,3 @@ +#%Module1.0 +module-whatis "badmodvers/foo" + diff --git a/testsuite/modules.80-deep/010-init_ts.exp b/testsuite/modules.80-deep/010-init_ts.exp index 8319d7e50..f4b1635c6 100644 --- a/testsuite/modules.80-deep/010-init_ts.exp +++ b/testsuite/modules.80-deep/010-init_ts.exp @@ -108,3 +108,9 @@ set idalias0 "moddalias" set odalias0 "moddalias/dir1/1" set idalias1 "moddalias/dir1" set odalias1 "moddalias/dir1/1" + +set cbadvers "badmodvers" +set ibadvers0 "badmodvers" +set obadvers0 "badmodvers/foo" +set ibadvers1 "badmodvers/dir1" +set obadvers1 "badmodvers/dir1/2.0" diff --git a/testsuite/modules.80-deep/020-load.exp b/testsuite/modules.80-deep/020-load.exp index ca6c5cbfb..c0d113a7d 100644 --- a/testsuite/modules.80-deep/020-load.exp +++ b/testsuite/modules.80-deep/020-load.exp @@ -200,6 +200,19 @@ lappend ans [list setpath _LMFILES_ "$p$odalias1"] test_cmd_re "csh" "load $idalias1" $ans +set ans [list] +lappend ans [list setpath LOADEDMODULES $obadvers0] +lappend ans [list setpath _LMFILES_ "$p$obadvers0"] +lappend ans [list ERR] +testouterr_cmd_re "csh" "load $ibadvers0" $ans "$error_msgs: Invalid ModulesVersion 'dir1/2.0' defined" + +set ans [list] +lappend ans [list setpath LOADEDMODULES $obadvers1] +lappend ans [list setpath _LMFILES_ "$p$obadvers1"] +lappend ans [list ERR] +testouterr_cmd_re "csh" "load $ibadvers1" $ans "$error_msgs: Invalid ModulesVersion 'dir1/2.0' defined" + + unset p unset ans diff --git a/testsuite/modules.80-deep/021-unload.exp b/testsuite/modules.80-deep/021-unload.exp index 7925f30f3..08a94d95c 100644 --- a/testsuite/modules.80-deep/021-unload.exp +++ b/testsuite/modules.80-deep/021-unload.exp @@ -38,6 +38,8 @@ set module_8 "modvirt/dir0/sub1/4.0" set modulefile_8 "$modulefile_5" set module_9 "moddalias/dir1/1" set modulefile_9 "$modpath/$module_9" +set module_10 "badmodvers/dir1/2.0" +set modulefile_10 "$modpath/$module_10" # @@ -225,6 +227,19 @@ testouterr_cmd "sh" "unload moddalias/dir1" $ans "" testouterr_cmd "sh" "unload moddalias" $ans "" +# set up the environment +set env(_LMFILES_) "$modulefile_10" +set env(LOADEDMODULES) "$module_10" + +set ans [list] +lappend ans [list unsetpath LOADEDMODULES] +lappend ans [list unsetpath _LMFILES_] + +testouterr_cmd "sh" "unload $module_10" $ans "" +testouterr_cmd "sh" "unload badmodvers/dir1" $ans "" +testouterr_cmd "sh" "unload badmodvers" $ans "" + + # # Cleanup # @@ -252,3 +267,5 @@ unset module_8 unset modulefile_8 unset module_9 unset modulefile_9 +unset module_10 +unset modulefile_10 diff --git a/testsuite/modules.80-deep/030-display.exp b/testsuite/modules.80-deep/030-display.exp index 1823bda2c..2fa153023 100644 --- a/testsuite/modules.80-deep/030-display.exp +++ b/testsuite/modules.80-deep/030-display.exp @@ -63,6 +63,10 @@ testouterr_cmd_re "csh" "display $ivirt8" "OK" "$modlin\n$pvirtre$mw$ovirt8$sv$o testouterr_cmd_re "csh" "display $idalias0" "OK" "$modlin\n$p$odalias0$mw$odalias0$nl" testouterr_cmd_re "csh" "display $idalias1" "OK" "$modlin\n$p$odalias1$mw$odalias1$nl" +set err_badvers "$error_msgs: Invalid ModulesVersion 'dir1/2.0' defined" +testouterr_cmd_re "csh" "display $ibadvers0" "ERR" "$err_badvers\n$modlin\n$p$obadvers0$mw$obadvers0$nl" +testouterr_cmd_re "csh" "display $ibadvers1" "ERR" "$err_badvers\n$modlin\n$p$obadvers1$mw$obadvers1$nl" + unset p unset lmf @@ -77,3 +81,5 @@ unset cf unset sv unset svs unset mdl + +unset err_badvers diff --git a/testsuite/modules.80-deep/050-whatis.exp b/testsuite/modules.80-deep/050-whatis.exp index b5d015c8b..0c4ac52df 100644 --- a/testsuite/modules.80-deep/050-whatis.exp +++ b/testsuite/modules.80-deep/050-whatis.exp @@ -32,4 +32,7 @@ testouterr_cmd_re "csh" "whatis $ivirt8" "OK" "$header\n\\s*$ovirt5: $ovirt5\\s* testouterr_cmd_re "csh" "whatis $idalias0" "OK" "$header\n $odalias0: $odalias0" testouterr_cmd_re "csh" "whatis $idalias1" "OK" "$header\n $odalias1: $odalias1" +testouterr_cmd_re "csh" "whatis $ibadvers0" "OK" "$header\n $obadvers1: $obadvers1\n $obadvers0: $obadvers0" +testouterr_cmd_re "csh" "whatis $ibadvers1" "OK" "$header\n $obadvers1: $obadvers1" + unset header diff --git a/testsuite/modules.80-deep/999-cleanup.exp b/testsuite/modules.80-deep/999-cleanup.exp index a22257749..40379103a 100644 --- a/testsuite/modules.80-deep/999-cleanup.exp +++ b/testsuite/modules.80-deep/999-cleanup.exp @@ -105,3 +105,9 @@ unset idalias0 unset odalias0 unset idalias1 unset odalias1 + +unset cbadvers +unset ibadvers0 +unset obadvers0 +unset ibadvers1 +unset obadvers1 diff --git a/testsuite/modules.90-avail/070-full.exp b/testsuite/modules.90-avail/070-full.exp index 0b7886771..ab8ffa809 100644 --- a/testsuite/modules.90-avail/070-full.exp +++ b/testsuite/modules.90-avail/070-full.exp @@ -127,6 +127,8 @@ info/shells loc_rcv2/2.0 modbad/is-avail info/shellsexp loc_sym/1.0 modbad/is-loaded spread/6.0 " set ts_sh_small "- $modpath.deep - +badmodvers/dir1/2.0 +badmodvers/foo dir2/1.0(d1) dir2/3.0(d3) modalias/1.0(@) @@ -197,6 +199,8 @@ version/dir2/2.0/rc2 version/dir2/3.0 " set ts_sh_noflag "- $modpath.deep - +badmodvers/dir1/2.0 +badmodvers/foo dir2/1.0 dir2/3.0 modalias/1.0 @@ -270,20 +274,20 @@ set len [string length $modpath.deep] set lrep [expr {($test_cols_othos - $len - 2)/2}] set rrep [expr {$test_cols_othos - $len - 2 - $lrep}] set ts_sh_noflag_othos "[string repeat {-} $lrep] $modpath.deep [string repeat {-} $rrep] -dir2/1.0 modsym/dir1/1.0 modtr/dir4/mod4.0 modvirt/dir0/sub1/5.0 trmod/al1 -dir2/3.0 modsym/dir2/2.0 modtr/dir5/subdir modvirt/dir0/sub1/6.0 trmod/al5 -modalias/1.0 modtr/3.0 modtr/dir5/subdir/mod5.0 modvirt/dir1/1.0 trmod/dir3 -modalias/3.0 modtr/al1 modulerc/dir1 modvirt/dir1/2.0 trmod/dir3/al2 -modalias/dir1/1.0 modtr/al4 modulerc/dir1/1.0 modvirt/dir2/2.0 version/dir1 -modalias/dir1/2.0 modtr/al5 modulerc/dir1/2.0 modvirt/dir2/3.0 version/dir1/1.0 -modalias/dir2/2.0 modtr/al6 modulerc/dir2/1.0 plain/dir1/1.0 version/dir1/2.0 -modalias/dir2/3.0 modtr/dir1/1.0 modulerc/dir2/1.0/rc1 plain/dir1/2.0 version/dir2/1.0 -moddalias modtr/dir2/2.0 modulerc/dir2/1.0/rc2 plain/dir2/1.0 version/dir2/2.0 -moddalias/dir1/1 modtr/dir3/al2 modulerc/dir2/2.0 plain/dir2/2.0 version/dir2/2.0/rc1 -moddef/dir2/1.0 modtr/dir3/al3 modulerc/dir2/3.0 tr2mod/al1 version/dir2/2.0/rc2 -moddef/dir2/2.0 modtr/dir4 modvirt/1.0 tr2mod/al5 version/dir2/3.0 -modload/dir2/1.0 modtr/dir4/al7 modvirt/3.0 tr2mod/dir3/al2 -modload/dir2/3.0 modtr/dir4/al8 modvirt/dir0/sub1/4.0 trmod " +badmodvers/dir1/2.0 modload/dir2/1.0 modtr/dir4/al7 modvirt/3.0 tr2mod/dir3/al2 +badmodvers/foo modload/dir2/3.0 modtr/dir4/al8 modvirt/dir0/sub1/4.0 trmod +dir2/1.0 modsym/dir1/1.0 modtr/dir4/mod4.0 modvirt/dir0/sub1/5.0 trmod/al1 +dir2/3.0 modsym/dir2/2.0 modtr/dir5/subdir modvirt/dir0/sub1/6.0 trmod/al5 +modalias/1.0 modtr/3.0 modtr/dir5/subdir/mod5.0 modvirt/dir1/1.0 trmod/dir3 +modalias/3.0 modtr/al1 modulerc/dir1 modvirt/dir1/2.0 trmod/dir3/al2 +modalias/dir1/1.0 modtr/al4 modulerc/dir1/1.0 modvirt/dir2/2.0 version/dir1 +modalias/dir1/2.0 modtr/al5 modulerc/dir1/2.0 modvirt/dir2/3.0 version/dir1/1.0 +modalias/dir2/2.0 modtr/al6 modulerc/dir2/1.0 plain/dir1/1.0 version/dir1/2.0 +modalias/dir2/3.0 modtr/dir1/1.0 modulerc/dir2/1.0/rc1 plain/dir1/2.0 version/dir2/1.0 +moddalias modtr/dir2/2.0 modulerc/dir2/1.0/rc2 plain/dir2/1.0 version/dir2/2.0 +moddalias/dir1/1 modtr/dir3/al2 modulerc/dir2/2.0 plain/dir2/2.0 version/dir2/2.0/rc1 +moddef/dir2/1.0 modtr/dir3/al3 modulerc/dir2/3.0 tr2mod/al1 version/dir2/2.0/rc2 +moddef/dir2/2.0 modtr/dir4 modvirt/1.0 tr2mod/al5 version/dir2/3.0 " # # test From 8b9ee25bff709656d627f52863c4841396161112 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Mon, 20 Aug 2018 17:26:20 +0200 Subject: [PATCH 28/28] Release of version 4.1.4 --- NEWS.rst | 23 +++++++++++++++++++++++ contrib/rpm/environment-modules.spec.in | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 6422f1ca5..ee2633d82 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,29 @@ This file describes changes in recent versions of Modules. It primarily documents those changes that are of interest to users and admins. +Modules 4.1.4 (2018-08-20) +-------------------------- + +* Doc: fix typo on ``getenv`` command description in modulefile(4) man page + and clarify this command should be preferred over ``::env`` variable to + query environment variable value in modulefile. +* Init: fix ``bash`` and ``zsh`` completion scripts to enable Extended Regular + Expression (ERE) on ``sed`` command with ``-E`` argument (rather ``-r``) for + compatibility with OS X's and BSDs' sed. (fix issue#178) +* Handle default version sets on an hidden modulefile (were not found + previously). (fix issue#177) +* Init: fix ``ksh`` initialization script for ksh88 compatibility. (fix + issue#159) +* Install: use ``sed`` command rather ``grep`` and ``cut`` in ``configure`` + and ``Makefile`` scripts. (fix issue#175 with contribution from Michael + Sternberg) +* Fix typo, tab indentation and pipe opening mode on ``createmodule.py`` + utility script. (contribution from Jan Synacek) +* Check ``ModulesVersion`` value set from ``.version`` rc file to ensure this + value refers to a version name in current directory. Report error if a + nested value is detected and ignore this value. (fix issue#176) + + Modules 4.1.3 (2018-06-18) -------------------------- diff --git a/contrib/rpm/environment-modules.spec.in b/contrib/rpm/environment-modules.spec.in index 81c78ae52..aab970981 100644 --- a/contrib/rpm/environment-modules.spec.in +++ b/contrib/rpm/environment-modules.spec.in @@ -1,7 +1,7 @@ %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) Name: environment-modules -Version: 4.1.3 +Version: 4.1.4 Release: @MODULES_RPM_RELEASE@%{?dist} Summary: Provides dynamic modification of a user's environment @@ -217,6 +217,9 @@ fi %changelog +* Mon Aug 20 2018 Xavier Delaruelle - 4.1.4-1 +- Update to 4.1.4 + * Mon Jun 18 2018 Xavier Delaruelle - 4.1.3-1 - Update to 4.1.3