Skip to content

Commit

Permalink
Add an option to checkcfgvar.pl to add defaults for missing variables.
Browse files Browse the repository at this point in the history
This eases the updates of the config.sh-format files when a new Configure
variable is added.
  • Loading branch information
nwc10 committed Sep 21, 2011
1 parent 7ee20c7 commit 818a19b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Porting/checkcfgvar.pl
Expand Up @@ -16,17 +16,19 @@
sub usage
{
my $err = shift and select STDERR;
print "usage: $0 [--list] [--regen]\n";
print "usage: $0 [--list] [--regen] [--default=value]\n";
exit $err;
} # usage

use Getopt::Long;
my $opt_l = 0;
my $opt_r = 0;
my $default;
GetOptions (
"help|?" => sub { usage (0); },
"l|list!" => \$opt_l,
"regen" => \$opt_r,
"default=s" => \$default,
) or usage (1);

require 'regen/regen_lib.pl' if $opt_r;
Expand Down Expand Up @@ -141,7 +143,10 @@ sub usage
}
for my $v (@MASTER_CFG) {
exists $cfg{$v} and next;
if ($opt_l) {
if (defined $default && $cfg ne 'configure.com') {
push @{$lines[1]}, "$v='$default'\n";
++$problems;
} elsif ($opt_l) {
# print the name once, for the first problem we encounter.
print "$cfg\n" unless $problems++;
}
Expand All @@ -150,6 +155,7 @@ sub usage
}
}
if ($problems && $opt_r) {
@{$lines[1]} = sort @{$lines[1]};
my $fh = open_new($cfg);
print $fh @{$_} foreach @lines;
close_and_rename($fh);
Expand Down

0 comments on commit 818a19b

Please sign in to comment.