Also warn about non-required values that are invalid
Before, only required values that were invalid produced a warning. Non-required values were quietly ignored.
This commit is contained in:
parent
05dbe7a984
commit
70858e659f
1 changed files with 16 additions and 13 deletions
17
ddclient.in
17
ddclient.in
|
@ -2026,13 +2026,14 @@ sub init_config {
|
||||||
# is to validate command-line options which were merged into %globals above.
|
# is to validate command-line options which were merged into %globals above.
|
||||||
# TODO: Move this check to where the command-line options are actually processed.
|
# TODO: Move this check to where the command-line options are actually processed.
|
||||||
my $value = check_value($ovalue, $def);
|
my $value = check_value($ovalue, $def);
|
||||||
# TODO: If the variable is not required, the value is set to undef but no warning is
|
if (!defined($value)) {
|
||||||
# logged. Is that intentional?
|
$ovalue //= '(not set)';
|
||||||
if ($def->{'required'} && !defined $value) {
|
warning("ignoring invalid $def->{type} variable value '$k=$ovalue'");
|
||||||
|
if ($def->{'required'}) {
|
||||||
# TODO: What's the point of this? The opt() function will fall back to the default
|
# TODO: What's the point of this? The opt() function will fall back to the default
|
||||||
# value if $globals{$k} is undefined.
|
# value if $globals{$k} is undefined.
|
||||||
$value = default($k);
|
$value = default($k);
|
||||||
warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value);
|
}
|
||||||
}
|
}
|
||||||
$globals{$k} = $value;
|
$globals{$k} = $value;
|
||||||
}
|
}
|
||||||
|
@ -2071,13 +2072,15 @@ sub init_config {
|
||||||
# $config{$h} above.
|
# $config{$h} above.
|
||||||
# TODO: Move this check to where --options is actually processed.
|
# TODO: Move this check to where --options is actually processed.
|
||||||
my $value = check_value($ovalue, $def);
|
my $value = check_value($ovalue, $def);
|
||||||
# TODO: If the variable is not required, the value is set to undef but no warning is
|
if (!defined($value)) {
|
||||||
# logged. Is that intentional?
|
|
||||||
if ($def->{'required'} && !defined $value) {
|
|
||||||
$ovalue //= '(not set)';
|
$ovalue //= '(not set)';
|
||||||
|
if ($def->{'required'}) {
|
||||||
warning("skipping host $h: invalid $def->{type} variable value '$k=$ovalue'");
|
warning("skipping host $h: invalid $def->{type} variable value '$k=$ovalue'");
|
||||||
delete $config{$h};
|
delete $config{$h};
|
||||||
next HOST;
|
next HOST;
|
||||||
|
} else {
|
||||||
|
warning("host $h: ignoring invalid $def->{type} variable value '$k=$ovalue'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$conf->{$k} = $value;
|
$conf->{$k} = $value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue