Update of /cvsroot/env-switcher/env-switcher/src
In directory usw-pr-cvs1:/tmp/cvs-serv1538/src
Modified Files:
switcher.in
Log Message:
- Enhanced announce attribute mechanism
- Updated man page to match new functionality
Index: switcher.in
===================================================================
RCS file: /cvsroot/env-switcher/env-switcher/src/switcher.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** switcher.in 18 May 2002 22:05:47 -0000 1.3
--- switcher.in 18 May 2002 23:44:05 -0000 1.4
***************
*** 278,281 ****
--- 278,320 ----
############################################################################
#
+ # resolve_announce
+ #
+ # Figure out which kind of announcements we want. Since this is a
+ # per-tag kind of decision, it's a subroutine. Load up the global
+ # variables $announce_load, $announce_warn, $announce_error to each be
+ # either 0 or 1.
+ #
+ ############################################################################
+
+ sub resolve_announce {
+ my ($a) = @_;
+ $announce_load = 0;
+ $announce_warn = 0;
+ $announce_error = 0;
+
+ if ($a eq "") {
+ $a = "warn,error";
+ } elsif ($a =~ /all/i) {
+ $a = "warn,error,load";
+ }
+
+ if (!$switcher_silent) {
+ if ($a =~ /all/i) {
+ $announce_error = $announce_warn = announce_load = 1;
+ }
+ if ($a =~ /warn/i) {
+ $announce_warn = 1;
+ }
+ if ($a =~ /error/i) {
+ $announce_error = 1;
+ }
+ if ($a =~ /load/i) {
+ $announce_load = 1;
+ }
+ }
+ }
+
+ ############################################################################
+ #
# list_tags
#
***************
*** 862,867 ****
my %attributes;
my $d, $a;
!
# Iterate through all the tags in the system file. Resolve each
# one.
--- 901,907 ----
my %attributes;
+ my %sys_tags;
my $d, $a;
!
# Iterate through all the tags in the system file. Resolve each
# one.
***************
*** 883,887 ****
$d = $attributes{$default_attribute};
! $a = $attributes{$announce_attribute};
# List the default tags
--- 923,927 ----
$d = $attributes{$default_attribute};
! resolve_announce($attributes{$announce_attribute});
# List the default tags
***************
*** 895,905 ****
# Print announcement notices
! if ($want_announce == 1 &&
! ($a =~ /true/i || $a eq "1")) {
! print "echo switcher:$tag: ";
! if (-f "$tag_dir/$tag/$d") {
! print "Loading $d;\n";
! } else {
! print "Cannot find modulefile for $d -- skipping;\n";
}
}
--- 935,959 ----
# Print announcement notices
! if ($want_announce && $d ne "" && $d ne "none") {
! if ($announce_load && -f "$tag_dir/$tag/$d") {
! print "echo switcher:$tag: Loading $d;\n";
! } elsif ($announce_warn) {
! print "echo switcher:$tag: Cannot find modulefile for $d -- skipping;\n";
! }
! }
! }
!
! # Now go see if there's any tags in the user file that are not in
! # the system default so that we can print out warnings.
!
! my %user_vars = $user_file->varlist(".*");
! foreach (keys(%user_vars)) {
! ($tag) = split(/_/, $_);
! %attributes = resolve_tag(0, 0);
! resolve_announce($attributes{$announce_attribute});
!
! if ($system_tags{$tag} != "1") {
! if ($announce_warn) {
! print "echo switcher: Tag \"$tag\" is in user defaults, but does not exist\n";
}
}
|