diff options
author | Jacob Pipkin <j@dawnrazor.net> | 2012-08-31 15:53:21 -0500 |
---|---|---|
committer | Jacob Pipkin <j@dawnrazor.net> | 2012-08-31 15:53:21 -0500 |
commit | d55dbdf17977ed9b1dfd91c98a4a569960b851cd (patch) | |
tree | 8e6a860de9fe0e8f5e52bc71716f6b4d69241c6d /sboconfig | |
parent | 12a1c8c4530ddb9ab83fec1f9b5bf61a25764e6b (diff) | |
download | sbotools2-d55dbdf17977ed9b1dfd91c98a4a569960b851cd.tar.xz |
epic changes and fixes and much further testing
Diffstat (limited to 'sboconfig')
-rwxr-xr-x | sboconfig | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; |