diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-29 14:34:43 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-29 14:34:43 -0700 |
commit | ba5606b762a0c41c0d060a000db93c2dde30b966 (patch) | |
tree | b1d7073089610c887b3eac84374935bd6c7eefc9 /scripts/vyatta-qos-util.pl | |
parent | 8908de129c7ae2d4e6bb70e81f0a5ed455cc9ca3 (diff) | |
download | vyatta-cfg-qos-ba5606b762a0c41c0d060a000db93c2dde30b966.tar.gz vyatta-cfg-qos-ba5606b762a0c41c0d060a000db93c2dde30b966.zip |
Fix handling of parameter validation
Can't use perl closures in getOptions, if routine exits, the error
from getOptions rather than as exit code.
Bug 4477
Diffstat (limited to 'scripts/vyatta-qos-util.pl')
-rwxr-xr-x | scripts/vyatta-qos-util.pl | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/scripts/vyatta-qos-util.pl b/scripts/vyatta-qos-util.pl index a429da4..9468065 100755 --- a/scripts/vyatta-qos-util.pl +++ b/scripts/vyatta-qos-util.pl @@ -43,13 +43,23 @@ EOF exit 1; } +my ($percent, $percentrate, $rate, $burst, $protocol, $dscp, $timeval); + GetOptions( - "percent=s" => sub { getPercent( $_[1] ); }, - "percent-or-rate=s" => sub { getPercentOrRate( $_[1] ); }, - "rate=s" => sub { getRate( $_[1] ); }, - "burst=s" => sub { getBurstSize( $_[1] ); }, - "protocol=s" => sub { getProtocol( $_[1] ); }, - "dscp=s" => sub { getDsfield( $_[1] ); }, - "tos=s" => sub { getDsfield( $_[1] ); }, - "time=s" => sub { getTime( $_[1] ); }, + "percent=s" => \$percent, + "percent-or-rate=s" => \$percentrate, + "rate=s" => \$rate, + "burst=s" => \$burst, + "protocol=s" => \$protocol, + "dscp=s" => \$dscp, + "tos=s" => \$dscp, + "time=s" => \$timeval, ) or usage(); + +getPercent($percent) if $percent; +getPercentOrRate($percent) if $percentrate; +getRate($rate) if $rate; +getBurstSize($burst) if $burst; +getProtocol($protocol) if $protocol; +getDsfield($dscp) if $dscp; +getTime($timeval) if $timeval; |