btrbk: allow "host:path" notation for command line arguments

pull/30/head
Axel Burri 2015-05-25 16:28:50 +02:00
parent 4295b3c019
commit 7b9021d5c8
1 changed files with 7 additions and 2 deletions

9
btrbk
View File

@ -1399,12 +1399,17 @@ MAIN:
# input validation # input validation
foreach (@subvol_args) { foreach (@subvol_args) {
s/\/+$//; # remove trailing slash s/\/+$//; # remove trailing slash
unless(/^(($ssh_prefix_match)?\/$file_match)$/) { # matches ssh statement or absolute file if(/^(($ssh_prefix_match)?\/$file_match)$/) { # matches ssh statement or absolute file
$_ = $1; # untaint argument
}
elsif(/^(?<host>$ip_addr_match|$host_name_match):\/(?<file>$file_match)$/) { # convert "my.host.com:/my/path" to ssh url
$_ = "ssh://$+{host}/$+{file}";
}
else {
ERROR "Bad argument: not a subvolume declaration: $_"; ERROR "Bad argument: not a subvolume declaration: $_";
HELP_MESSAGE(0); HELP_MESSAGE(0);
exit 1; exit 1;
} }
$_ = $1; # untaint argument
} }