From c18d77d981137ee672823a317bd7138113a59ba5 Mon Sep 17 00:00:00 2001 From: buty4649 Date: Sun, 24 Mar 2024 19:14:06 +0900 Subject: [PATCH] Refactor output handling in runCommand function --- iproute2/base.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iproute2/base.go b/iproute2/base.go index 1a38617..c2e5325 100644 --- a/iproute2/base.go +++ b/iproute2/base.go @@ -81,17 +81,16 @@ func (b *BaseCommand) runCommand(cmd []string, input *string) (string, error) { }() } - stdout, err := c.Output() + out, err := c.CombinedOutput() if err != nil { exitErr, _ := err.(*exec.ExitError) status, _ := exitErr.Sys().(syscall.WaitStatus) - stderr := string(exitErr.Stderr) return "", &CommandError{ ExitStatus: status.ExitStatus(), - Msg: stderr, + Msg: string(out), } } - return string(stdout), nil + return string(out), nil } func (b *BaseCommand) AddLink(name string, linkType string, options ...string) error {