diff --git a/pkg/commands/os.go b/pkg/commands/os.go index b2fd42ec..22490b49 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -115,11 +115,12 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) { outputString := string(output) if err != nil { // errors like 'exit status 1' are not very useful so we'll create an error - // from the combined output - if outputString == "" { - return "", WrapError(err) + // from stderr if we got an ExitError + exitError, ok := err.(*exec.ExitError) + if ok { + return outputString, errors.New(string(exitError.Stderr)) } - return outputString, errors.New(outputString) + return "", WrapError(err) } return outputString, nil }