From 381a12241b38cf991d003ad76f5b07c1bdef4f93 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sun, 28 Jul 2019 18:54:28 +0200 Subject: [PATCH] btrbk: add dir_args: relative path arguments for actions reqiring directories Preparatory for action "ls". --- btrbk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/btrbk b/btrbk index 7cd6278..13aa7f8 100755 --- a/btrbk +++ b/btrbk @@ -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 @filter_args; my @subvol_args; + my @dir_args; my $args_expected_min = 0; my $args_expected_max = 9999; if(($command eq "run") || ($command eq "dryrun")) { @@ -4987,6 +4988,20 @@ MAIN: } $_ = $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; foreach (@filter_args) { my $vf = vinfo_filter_statement($_);