Hi,
I'm trying to set up some module files to run based on how they are
invoked, eg, load/add/switch. My main focus is switch though.
This is so I know when it is ok to run some commands, like [exec ...] for
instance, that are based on PATHs being set correctly.
I do this by getting [module-info mode] and running a regexp to see if it
is a load or switch action, ie:
set MODNAME [module-info name]
set MODMODE [module-info mode]
regexp {^switch[123]|^load} [module-info mode] OKMODE
if {[info exists OKMODE]} {
puts "OKMODE: $OKMODE"
puts stderr "We're ($MODMODE)ing this ($MODNAME) stuff."
prepend-path PATH /path/to/scripts
set SCRIPT [exec which script.sh]
...
} else {
<don't run [exec which script.sh]>
}
I've found there is a 3 stage switch rocket happening (switch1/2/3), and
that I can switch modules if I skip checking for switch2 for example. Ie,
the regexp above run as follows seems to be ok:
regexp {^switch[13]|^load} [module-info mode] OKMODE
If I run the regexp on all 3 switch variations (regexp {^switch[123]...) my
if statement checking for OKMODE fails:
module switch test/a/0.5 test/a/0.3
OKMODE: switch1
We're (switch1)ing this (test/a/0.5) stuff.
test/a/0.5(20):ERROR:102: Tcl command execution failed: if {[info exists
OKMODE]} {
puts stderr "OKMODE: $OKMODE"
puts stderr "We're ($MODMODE)ing this ($MODNAME) stuff."
...
So my main question is what is the actual (modulecmd) process when
switching modules? Ie, are the different switch "modes"
(switch1/switch2/switch3) equivalent to a switch-rm and switch-load for
example?
Regards,
Tony
|