Debian Codegraph @

share/modulefiles/version.in

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