btrbk: fixed bug: "Use of uninitialized value $&". The bug occurred when parsing a sub-subvolume from "btrfs subvolume list" command output

pull/30/head
Axel Burri 2015-03-11 19:18:54 +01:00
parent 448b70b8fd
commit 02acb32d17
1 changed files with 9 additions and 6 deletions

13
btrbk
View File

@ -664,14 +664,17 @@ sub btr_subtree($;$)
my $path = $node->{path}; my $path = $node->{path};
if($volname) { if($volname) {
# strip leading volume name # strip leading volume name
unless($path =~ s/^$volname\///) { if($path =~ s/^$volname\///) {
# if $vol is a sub-subvolume, strip whole prefix TRACE "btr_subtree: removed \"$&\" prefix of subvolume path: $path";
unless($path =~ s/.+\/$volname\///) { }
elsif($path =~ s/^.+\/$volname\///) {
# $vol is a sub-subvolume, whole prefix stripped
TRACE "btr_subtree: removed \"$&\" prefix of sub-subvolume path: $path";
}
else {
die("ambiguous btrfs subvolume info line"); die("ambiguous btrfs subvolume info line");
} }
} }
TRACE "btr_subtree: removed \"$&\" prefix of subvolume path: $path";
}
$node->{SUBVOL_PATH} = $path; $node->{SUBVOL_PATH} = $path;
TRACE "btr_subtree: set SUBVOL_PATH: $node->{SUBVOL_PATH}"; TRACE "btr_subtree: set SUBVOL_PATH: $node->{SUBVOL_PATH}";