From 90cd9a74b8b562bebd4a2eaeb01ccdb3d2a75c42 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sat, 1 Sep 2012 02:22:57 -0500 Subject: fix >> to > --- sboconfig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sboconfig b/sboconfig index aca2ad1..e993430 100755 --- a/sboconfig +++ b/sboconfig @@ -97,8 +97,8 @@ sub config_write ($$) { my $conffh = open_read $conf_file; my $conftents = do {local $/; <$conffh>}; print {$tempfh} $conftents; - # tie the file so that if $key is already there, we just change that - # line and untie it + # tie the temp file so that if $key is already there, we just change + # that line and untie it tie my @temp, 'Tie::File', $tempfh; my $has; my $regex = qr/\A\Q$key\E=/; @@ -108,11 +108,12 @@ sub config_write ($$) { untie @temp; # otherwise, append our new $key=$value pair print {$tempfh} "$key=$val\n" unless $has; + # then over the conf file with the contents of the temp file seek $tempfh, 0, 0; my $contents = do {local $/; <$tempfh>}; close $conffh; - eval { $conffh = open_fh $conf_file, '>>' }; - warn "Cannot write configuration: $@\n", return if $@; + eval { $conffh = open_fh $conf_file, '>' }; + warn "Cannot write configuration: $@\n" and return if $@; print {$conffh} $contents or return; close $conffh, close $tempfh; } else { -- cgit v1.2.3