Use parse_assignments
to process --options
This simplifies the code and enables quoting of special characters.
This commit is contained in:
parent
270a82dd58
commit
bbf98dd031
1 changed files with 6 additions and 19 deletions
25
ddclient.in
25
ddclient.in
|
@ -1913,17 +1913,12 @@ sub init_config {
|
||||||
|
|
||||||
## define or modify host options specified on the command-line
|
## define or modify host options specified on the command-line
|
||||||
if (defined($opt{'options'})) {
|
if (defined($opt{'options'})) {
|
||||||
## collect cmdline configuration options.
|
# TODO: Perhaps the --options argument should be processed like the contents of the config
|
||||||
my %options = ();
|
# file: each line (after removing any comments or continuations) either specifies global
|
||||||
for my $opt (split_by_comma($opt{'options'})) {
|
# values or host-specific settings. For now, non-value newlines and end-of-line host
|
||||||
my ($name, $var) = split /\s*=\s*/, $opt;
|
# declarations are rejected.
|
||||||
if ($name eq 'fw-banlocal' || $name eq 'if-skip') {
|
my ($rest, %options) = parse_assignments($opt{'options'});
|
||||||
warning("'$name' is deprecated and does nothing");
|
fatal("unexpected content in '--options' argument: $rest") if $rest ne '';
|
||||||
next;
|
|
||||||
}
|
|
||||||
# TODO: Shouldn't *_env options be processed like _read_config does?
|
|
||||||
$options{$name} = $var;
|
|
||||||
}
|
|
||||||
## determine hosts specified with --host
|
## determine hosts specified with --host
|
||||||
my @hosts = ();
|
my @hosts = ();
|
||||||
if (exists $opt{'host'}) {
|
if (exists $opt{'host'}) {
|
||||||
|
@ -1998,11 +1993,6 @@ sub init_config {
|
||||||
## make sure config entries have all defaults and they meet minimums
|
## make sure config entries have all defaults and they meet minimums
|
||||||
## first the globals...
|
## first the globals...
|
||||||
for my $k (keys %globals) {
|
for my $k (keys %globals) {
|
||||||
# Make sure any _env suffixed variables look at their original entry
|
|
||||||
# TODO: Didn't _read_config already handle *_env? Or is this needed to handle
|
|
||||||
# the --options command-line option whose values were merged into %globals above?
|
|
||||||
$k = $1 if $k =~ /^(.*)_env$/;
|
|
||||||
|
|
||||||
# TODO: This might grab an arbitrary protocol-specific variable, which could cause
|
# TODO: This might grab an arbitrary protocol-specific variable, which could cause
|
||||||
# surprising behavior.
|
# surprising behavior.
|
||||||
my $def = $variables{'merged'}{$k};
|
my $def = $variables{'merged'}{$k};
|
||||||
|
@ -2050,9 +2040,6 @@ sub init_config {
|
||||||
|
|
||||||
# TODO: This silently ignores unknown options passed via --options.
|
# TODO: This silently ignores unknown options passed via --options.
|
||||||
for my $k (keys %$svars) {
|
for my $k (keys %$svars) {
|
||||||
# Make sure any _env suffixed variables look at their original entry
|
|
||||||
$k = $1 if $k =~ /^(.*)_env$/;
|
|
||||||
|
|
||||||
my $def = $svars->{$k};
|
my $def = $svars->{$k};
|
||||||
# TODO: Why doesn't this try %opt and %globals before falling back to the variable
|
# TODO: Why doesn't this try %opt and %globals before falling back to the variable
|
||||||
# default? By ignoring %opt and %globals, `--options` will not have any effect on any
|
# default? By ignoring %opt and %globals, `--options` will not have any effect on any
|
||||||
|
|
Loading…
Reference in a new issue