btrbk: add dir_args: relative path arguments for actions reqiring directories

Preparatory for action "ls".
pull/293/head
Axel Burri 2019-07-28 18:54:28 +02:00
parent 217317b274
commit 381a12241b
1 changed files with 15 additions and 0 deletions

15
btrbk
View File

@ -4879,6 +4879,7 @@ MAIN:
my ($action_run, $action_usage, $action_resolve, $action_diff, $action_origin, $action_config_print, $action_list, $action_clean, $action_archive); my ($action_run, $action_usage, $action_resolve, $action_diff, $action_origin, $action_config_print, $action_list, $action_clean, $action_archive);
my @filter_args; my @filter_args;
my @subvol_args; my @subvol_args;
my @dir_args;
my $args_expected_min = 0; my $args_expected_min = 0;
my $args_expected_max = 9999; my $args_expected_max = 9999;
if(($command eq "run") || ($command eq "dryrun")) { if(($command eq "run") || ($command eq "dryrun")) {
@ -4987,6 +4988,20 @@ MAIN:
} }
$_ = $url_prefix . $path; $_ = $url_prefix . $path;
} }
foreach (@dir_args) {
# map relative path to absolute
my $path = $_;
if(-d $path) {
$path = `readlink -e -q '$path'`;
}
$path = check_file($path, { absolute => 1 });
unless($path) {
ERROR "Bad argument: not a directory: $_";
HELP_MESSAGE(0);
exit 2;
}
$_ = $path;
}
my @filter_vf; my @filter_vf;
foreach (@filter_args) { foreach (@filter_args) {
my $vf = vinfo_filter_statement($_); my $vf = vinfo_filter_statement($_);