From d55dbdf17977ed9b1dfd91c98a4a569960b851cd Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Fri, 31 Aug 2012 15:53:21 -0500 Subject: epic changes and fixes and much further testing --- sboconfig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sboconfig') diff --git a/sboconfig b/sboconfig index 9c2682f..2065a27 100755 --- a/sboconfig +++ b/sboconfig @@ -98,7 +98,7 @@ sub config_write ($$) { # tie the file so that if $key is already there, we just change that # line and untie it tie my @temp, 'Tie::File', $tempfn; - my $has = 0; + my $has; my $regex = qr/\A\Q$key\E=/; FIRST: for my $tmpline (@temp) { $has++, $tmpline = "$key=$val", last FIRST if $tmpline =~ $regex; @@ -110,18 +110,19 @@ sub config_write ($$) { print {$fh} "$key=$val\n"; close $fh; } - move ($tempfn, $conf_file); + move ($tempfn, $conf_file) || return; } else { # no config file, easiest case of all. - my $fh = open_fh $conf_file, '>'; + my $fh = open_fh $conf_file, '>' || return; say {$fh} "$key=$val"; close $fh; } + return 1; } while (my ($key, $value) = each %changes) { print "Setting $key to $value...\n"; - config_write $key, $value; + config_write $key, $value or warn "Unable to write to $conf_file\n"; } exit 0; -- cgit v1.2.3