Skip to content

Commit

Permalink
Merge pull request #18 from buty4649/combinedout
Browse files Browse the repository at this point in the history
Refactor output handling in runCommand function
  • Loading branch information
buty4649 authored Mar 24, 2024
2 parents 2539fc0 + c18d77d commit ab4a723
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 ab4a723

Please sign in to comment.