Permalink
Browse files

added usage error for no args or 3 args

  • Loading branch information...
1 parent 72355e5 commit bfd0c4eba2e3299cc77f238005ef2b2e5d4af3df @teleshoes committed Jan 9, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 led-controls/led
View
@@ -2,7 +2,10 @@
use strict;
use warnings;
+my $usage = "Usage: $0 <led> [<on|off|toggle> | brightness]\n";
my $name = shift;
+die $usage if not defined $name;
+
$name = '' if not defined $name;
$name =~ s/^tpacpi://;
$name = ":$name" if $name !~ /:/;
@@ -15,8 +18,8 @@ $name = $1; #untaint
my $brightness = shift;
$brightness = 'toggle' if not defined $brightness;
-if($brightness !~ /^(on|off|toggle|\d+)$/i){
- die "Usage: $0 <led> [<on|off|toggle> | brightness]\n";
+if(@ARGV > 0 or $brightness !~ /^(on|off|toggle|\d+)$/i){
+ die $usage;
}
$brightness = $1; #untaint

0 comments on commit bfd0c4e

Please sign in to comment.