From 798133c3956e75fcd858cd4d429610e5046f325b Mon Sep 17 00:00:00 2001 From: Ekene Izukanne Date: Fri, 22 Sep 2023 01:48:28 +0100 Subject: [PATCH] fix: return buffered stderr only when there are available bytes --- internal/utils/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 3ddff6c..9dcc3e6 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -44,7 +44,7 @@ func GetShellCommandOutput(command string, args ...string) (string, error) { var stderr bytes.Buffer cmd.Stderr = &stderr out, err := cmd.Output() - if err != nil { + if err != nil && stderr.Available() != 0 { return string(out), errors.New(stderr.String()) } return string(out), err @@ -56,7 +56,7 @@ func GetShellCommandOutputWithEnv(env []string, command string, args ...string) var stderr bytes.Buffer cmd.Stderr = &stderr out, err := cmd.Output() - if err != nil { + if err != nil && stderr.Available() != 0 { return string(out), errors.New(stderr.String()) } return string(out), err