config.pl get: don't rewrite config.h; detect write errors
scripts/config.pl would always rewrite config.h if it was reading it. This commit changes it to not modify the file when only reading is required, i.e. for the get command. Also, die if writing config.h fails (e.g. disk full).
This commit is contained in:
parent
f0f55ccb72
commit
01f57e351c
1 changed files with 11 additions and 4 deletions
|
@ -175,7 +175,10 @@ if ($action eq "realfull") {
|
|||
$no_exclude_re = join '|', @non_excluded;
|
||||
}
|
||||
|
||||
open my $config_write, '>', $config_file or die "write $config_file: $!\n";
|
||||
my $config_write = undef;
|
||||
if ($action ne "get") {
|
||||
open $config_write, '>', $config_file or die "write $config_file: $!\n";
|
||||
}
|
||||
|
||||
my $done;
|
||||
for my $line (@config_lines) {
|
||||
|
@ -211,7 +214,9 @@ for my $line (@config_lines) {
|
|||
}
|
||||
}
|
||||
|
||||
print $config_write $line;
|
||||
if (defined $config_write) {
|
||||
print $config_write $line or die "write $config_file: $!\n";;
|
||||
}
|
||||
}
|
||||
|
||||
# Did the set command work?
|
||||
|
@ -223,10 +228,12 @@ if ($action eq "set"&& $force_option && !$done) {
|
|||
$line .= "\n";
|
||||
$done = 1;
|
||||
|
||||
print $config_write $line;
|
||||
print $config_write $line or die "write $config_file: $!\n";
|
||||
}
|
||||
|
||||
close $config_write;
|
||||
if (defined $config_write) {
|
||||
close $config_write or die "close $config_file: $!\n";
|
||||
}
|
||||
|
||||
if ($action eq "get") {
|
||||
if($done) {
|
||||
|
|
Loading…
Reference in a new issue