From 2c0bac75e124fe1497b5718abf5b2a13a5de0a00 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 7 Jun 2011 18:08:29 +0200 Subject: [PATCH] bin/battery.pl: Add checks and correct exit code. --- bin/battery.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- 2.44.1