From 4336af295f9c76f4fc79fd91e1f4c2e98eb9e3e2 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Tue, 4 Sep 2018 13:30:52 -0700 Subject: [PATCH] fixup 22ca80eb7e71c10eba577e96e8356922d42ed8f3: scraping regex was broken and potentially mixed with stdout --- zfs/zfs.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zfs/zfs.go b/zfs/zfs.go index 577449e..a218c72 100644 --- a/zfs/zfs.go +++ b/zfs/zfs.go @@ -477,7 +477,7 @@ func ZFSGet(fs *DatasetPath, props []string) (*ZFSProperties, error) { return zfsGet(fs.ToString(), props) } -var zfsGetDatasetDoesNotExistRegexp = regexp.MustCompile(`^cannot open '(\s+)': dataset does not exist`) +var zfsGetDatasetDoesNotExistRegexp = regexp.MustCompile(`^cannot open '(\S+)': dataset does not exist`) type DatasetDoesNotExist struct { Path string @@ -488,12 +488,12 @@ func (d *DatasetDoesNotExist) Error() string { return fmt.Sprintf("dataset %q do func zfsGet(path string, props []string) (*ZFSProperties, error) { args := []string{"get", "-Hp", "-o", "property,value", strings.Join(props, ","), path} cmd := exec.Command(ZFS_BINARY, args...) - output, err := cmd.CombinedOutput() + stdout, err := cmd.Output() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { if exitErr.Exited() { // screen-scrape output - if sm := zfsGetDatasetDoesNotExistRegexp.FindSubmatch(output); sm != nil { + if sm := zfsGetDatasetDoesNotExistRegexp.FindSubmatch(exitErr.Stderr); sm != nil { if string(sm[1]) == path { return nil, &DatasetDoesNotExist{path} } @@ -502,7 +502,7 @@ func zfsGet(path string, props []string) (*ZFSProperties, error) { } return nil, err } - o := string(output) + o := string(stdout) lines := strings.Split(o, "\n") if len(lines) < 1 || // account for newlines len(lines)-1 != len(props) {