1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#%Module
module-help { version - initializes new version of the module command.}
module-help " Version $::version"
module-help {}
module-whatis {initializes new version of the module command}
# for Tcl script use only
set version @VERSION@
set shell [module-info shell]
# get rid of old version
if {[module-info mode] in {load display}} {
module unload --not-req null
module unload --not-req modules
setenv MODULE_VERSION @VERSION@
}
# version stack
prepend-path MODULE_VERSION_STACK @VERSION@
if {[module-info mode remove]} {
# unload modules modulefile to get PATHs refreshed after previous module
# command restoration
module load modules
set prevversion [lindex [split $env(MODULE_VERSION_STACK) :] 0]
unsetenv MODULE_VERSION $prevversion
# re-initialize previous module command version by sourcing its
# initialization script, as module function definition is not compatible
# between Modules 3 and Modules 4
switch -- $shell {
sh - bash - ksh - zsh - csh - tcsh - fish {
set versionre [regsub -all "\(\[.+?\]\)" $version {\\\1}]
regsub $versionre "@initdir@/$shell" $prevversion previnitshell
if {[file exists $previnitshell]} {
switch -- $shell {
sh - bash - ksh - zsh {
set sourcecmd .
}
csh - tcsh - fish {
set sourcecmd source
}
}
puts stdout "$sourcecmd $previnitshell"
puts stdout {module load modules}
} else {
puts stderr "No initialization script for '$shell' on version '$prevversion'"
}
}
default {
# no support for re-initializing module command on scripting shell
# as it is not a common practice for most of these languages to
# redefine an already set function
puts stderr "No re-initialization supported for '$shell' on version '$prevversion'"
}
}
}
# bring in new version
if {[module-info mode] in {load display}} {
module load modules
puts stdout [exec @TCLSH@ {@libexecdir@/modulecmd.tcl} $shell autoinit]
}
|