|
From: Jeff S. <jsq...@us...> - 2003-07-19 18:11:36
|
Update of /cvsroot/env-switcher/env-switcher/src
In directory sc8-pr-cvs1:/tmp/cvs-serv2429/src
Modified Files:
switcher.tcl.in
Log Message:
Updates to handle multiple default files; need to handle "split" of
"switcher --show-exec" output, as well as pass through any error output
lines. Thanks to Justin MacCallum for pointing this out.
Index: switcher.tcl.in
===================================================================
RCS file: /cvsroot/env-switcher/env-switcher/src/switcher.tcl.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** switcher.tcl.in 11 Oct 2002 17:00:45 -0000 1.9
--- switcher.tcl.in 19 Jul 2003 18:11:33 -0000 1.10
***************
*** 1,6 ****
#%Module -*- tcl -*-
#
! # Copyright (c) 2002 The Trustees of Indiana University.
! # All rights reserved.
#
# This file is part of the Env-switcher software package. For license
--- 1,6 ----
#%Module -*- tcl -*-
#
! # Copyright (c) 2002-2003 The Trustees of Indiana University.
! # All rights reserved.
#
# This file is part of the Env-switcher software package. For license
***************
*** 23,26 ****
--- 23,54 ----
module-whatis "Sets up the OSCAR switcher subsystem."
+ proc process_switcher_output {action output} {
+
+ # We may well have gotten multiple lines from the output of
+ # switcher. So split them by \n, and process them individually.
+
+ set lines [split $output "\n"]
+ foreach line $lines {
+
+ # If we got a line beginning with "echo", then switcher just
+ # wanted this line output. So just output it.
+
+ if { [string first "echo" $line] == 0 } {
+ puts "$line"
+ } else {
+
+ # Otherwise, it was a module name. So either load or unload it.
+
+ if { [string compare "load" $action] == 0 } {
+ module load $line
+ } elseif { [string compare "unload" $action] == 0 } {
+ module unload $line
+ } else {
+ puts "echo ERROR: Unknown switcher action ($action): '$line' ignored;"
+ }
+ }
+ }
+ }
+
# If we're removing the switcher module, unload all the modules that
# switcher loaded.
***************
*** 30,41 ****
if { $have_switcher && $am_removing } {
! set announce_output [exec switcher --announce]
! if { $announce_output != ""} {
! puts "$announce_output"
! }
! set modules_to_load [exec switcher --show-exec]
! if { $modules_to_load != "" } {
! module unload $modules_to_load
! }
}
--- 58,63 ----
if { $have_switcher && $am_removing } {
! process_switcher_output "announce" [exec switcher --announce]
! process_switcher_output "unload" [exec switcher --show-exec]
}
***************
*** 54,61 ****
if { $have_switcher && ! $am_removing } {
! set announce_output [exec switcher --announce]
! if { $announce_output != ""} {
! puts "$announce_output"
! }
# Now invoke the switcher perl script to get a list of the modules
--- 76,80 ----
if { $have_switcher && ! $am_removing } {
! process_switcher_output "announce" [exec switcher --announce]
# Now invoke the switcher perl script to get a list of the modules
***************
*** 63,69 ****
# them. Only do this if we're loading the module.
! set modules_to_load [exec switcher --show-exec]
! if { $modules_to_load != "" } {
! module load $modules_to_load
! }
}
--- 82,85 ----
# them. Only do this if we're loading the module.
! process_switcher_output "load" [exec switcher --show-exec]
}
|