Skip to content

Commit

Permalink
Refactor output handling in runCommand function
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 committed Mar 24, 2024
1 parent 2539fc0 commit c18d77d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions iproute2/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c18d77d

Please sign in to comment.