correctly parse zfs column output (space can be included in the values)

This commit is contained in:
Christoph Klaffl 2018-06-21 18:18:28 +02:00
parent 9d387c013f
commit 34b942ea45
No known key found for this signature in database
GPG Key ID: FC1C525C2A47CC28
2 changed files with 6 additions and 6 deletions

2
sanoid
View File

@ -521,7 +521,7 @@ sub getsnaps {
}
foreach my $snap (@rawsnaps) {
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*ly)\s*creation\s*(\d*)/);
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*ly)\t*creation\t*(\d*)/);
# avoid pissing off use warnings
if (defined $snapname) {

10
syncoid
View File

@ -664,7 +664,7 @@ sub getzfsvalue {
open FH, "$rhost $mysudocmd $zfscmd get -H $property $fsescaped |";
my $value = <FH>;
close FH;
my @values = split(/\s/,$value);
my @values = split(/\t/,$value);
$value = $values[2];
return $value;
}
@ -985,7 +985,7 @@ sub getsnaps() {
if ($line =~ /\Q$fs\E\@.*guid/) {
chomp $line;
my $guid = $line;
$guid =~ s/^.*\sguid\s*(\d*).*/$1/;
$guid =~ s/^.*\tguid\t*(\d*).*/$1/;
my $snap = $line;
$snap =~ s/^.*\@(.*)\tguid.*$/$1/;
$snaps{$type}{$snap}{'guid'}=$guid;
@ -997,7 +997,7 @@ sub getsnaps() {
if ($line =~ /\Q$fs\E\@.*creation/) {
chomp $line;
my $creation = $line;
$creation =~ s/^.*\screation\s*(\d*).*/$1/;
$creation =~ s/^.*\tcreation\t*(\d*).*/$1/;
my $snap = $line;
$snap =~ s/^.*\@(.*)\tcreation.*$/$1/;
$snaps{$type}{$snap}{'creation'}=$creation;
@ -1056,9 +1056,9 @@ sub getsendsize {
# the output format is different in case of
# a resumed receive
if (defined($receivetoken)) {
$sendsize =~ s/.*\s([0-9]+)$/$1/;
$sendsize =~ s/.*\t([0-9]+)$/$1/;
} else {
$sendsize =~ s/^size\s*//;
$sendsize =~ s/^size\t*//;
}
chomp $sendsize;