From: Simon Ruderich Date: Tue, 7 Jun 2011 16:08:29 +0000 (+0200) Subject: bin/battery.pl: Add checks and correct exit code. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=2c0bac75e124fe1497b5718abf5b2a13a5de0a00;p=config%2Fdotfiles.git bin/battery.pl: Add checks and correct exit code. --- diff --git a/bin/battery.pl b/bin/battery.pl index 6a9ce2c..407e0bc 100755 --- a/bin/battery.pl +++ b/bin/battery.pl @@ -9,7 +9,7 @@ my $path = '/sys/class/power_supply/BAT0/uevent'; # No battery available. if (! -e $path) { - exit; + exit 1; } my $screen_mode = (defined $ARGV[0] and $ARGV[0] eq '-s'); @@ -17,7 +17,7 @@ my $tmux_mode = (defined $ARGV[0] and $ARGV[0] eq '-t'); my %battery; -open my $file, '<', $path; +open my $file, '<', $path or die $!; while (<$file>) { /^POWER_SUPPLY_([A-Z_]+)=(.+)$/; $battery{$1} = $2;