summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-16 09:56:35 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-16 09:56:35 -0700
commit8b782b88bd535d739166d21a4cbb95931fff2ce0 (patch)
treecc2cd62124edcef78ce6d86a11128ec63ab4a85a
parentac7832987028d915b92abd718d2bc5212d301e8b (diff)
downloadvyatta-cfg-quagga-8b782b88bd535d739166d21a4cbb95931fff2ce0.tar.gz
vyatta-cfg-quagga-8b782b88bd535d739166d21a4cbb95931fff2ce0.zip
Don't use closure in GetOptions
Although it looks cleaner, the error handling for closures is different. Exit in closure from GetOptions, only fails the option not the program.
-rwxr-xr-xscripts/vyatta_quagga_utils.pl18
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl
index c59bc87e..55254cbb 100755
--- a/scripts/vyatta_quagga_utils.pl
+++ b/scripts/vyatta_quagga_utils.pl
@@ -6,12 +6,19 @@ use Vyatta::Misc;
use NetAddr::IP;
use Getopt::Long;
-GetOptions("check-prefix-boundry=s" => sub { check_prefix_boundry( $_[1] ); },
- "not-exists=s" => sub { check_not_exists($_[1]); },
- "exists=s" => sub { check_exists($_[1]); },
- "check-ospf-area=s" => sub { check_ospf_area($_[1]); },
+my ($prefix, $exists, $not_exists, $area);
+
+GetOptions("check-prefix-boundry=s" => \$prefix,
+ "not-exists=s" => \$not_exists,
+ "exists=s" => \$exists,
+ "check-ospf-area=s" => \$area,
);
+check_prefix_boundry($prefix) if ($prefix);
+check_not_exists($not_exists) if ($not_exists);
+check_exists($exists) if ($exists);
+check_ospf_area($area) if ($area);
+
exit 0;
sub check_prefix_boundry {
@@ -62,6 +69,7 @@ sub check_ospf_area {
}
exit 0
}
- exit 1;
+
+ die "Invalid OSPF area: $area\n";
}