fix: Check return code of zfs command for FreeBSD. (#9956)

This commit is contained in:
Sven Rebhan 2021-10-21 17:51:23 +02:00 committed by GitHub
parent 8f35d74c5e
commit aa2f1b150e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -174,9 +174,12 @@ func run(command string, args ...string) ([]string, error) {
stdout := strings.TrimSpace(outbuf.String())
stderr := strings.TrimSpace(errbuf.String())
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("%s error: %s", command, stderr)
}
return nil, fmt.Errorf("%s error: %s", command, err)
}
return strings.Split(stdout, "\n"), nil
}