btrbk: allow overriding options with context restrictions

This allows commands like:

    btrbk run mysubvol --override=snapshot_name=mysubvol-oneshot
pull/286/head
Axel Burri 2019-04-30 13:38:47 +02:00
parent 3d169d1df4
commit 206e706d85
1 changed files with 2 additions and 2 deletions

4
btrbk
View File

@ -3599,7 +3599,7 @@ sub append_config_option($$$$;@)
return undef;
}
if($opt->{context} && !grep(/^$context$/, @{$opt->{context}})) {
if($opt->{context} && !grep(/^$context$/, @{$opt->{context}}) && ($context ne "OVERRIDE")) {
ERROR "Option \"$key\" is only allowed in " . join(" or ", map("\"$_\"", @{$opt->{context}})) . " context $error_statement";
return undef;
}
@ -4963,7 +4963,7 @@ MAIN:
my $key = $1;
my $value = $2;
DEBUG "config_override: \"$key=$value\"";
unless(append_config_option(\%config_override, $key, $value, "root", error_statement => "in option \"--override\"")) {
unless(append_config_option(\%config_override, $key, $value, "OVERRIDE", error_statement => "in option \"--override\"")) {
HELP_MESSAGE(0);
exit 2;
}