Skip to content

Commit

Permalink
fix: showing the entire error message when a command fails
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed May 14, 2021
1 parent 82dd30c commit dfe64ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Exec(executable string, args []string) (string, error) {

raw, err := exec.Command(path, args...).CombinedOutput()
if err != nil {
return "", err
return str.Trim(string(raw)), err
} else {
return str.Trim(string(raw)), nil
}
Expand Down
9 changes: 6 additions & 3 deletions network/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ func SetWiFiRegion(region string) error {

func ActivateInterface(name string) error {
if out, err := core.Exec("ifconfig", []string{name, "up"}); err != nil {
return err
if out != "" {
return fmt.Errorf("%v: %s", err, out)
} else {
return err
}
} else if out != "" {
return fmt.Errorf("unexpected output while activating interface %s: %s", name, out)
}
Expand All @@ -289,8 +293,7 @@ func ActivateInterface(name string) error {
func SetInterfaceTxPower(name string, txpower int) error {
if core.HasBinary("iw") {
Debug("SetInterfaceTxPower(%s, %d) iw based", name, txpower)
if _, err := core.Exec("iw", []string{"dev", name, "set", "txpower", "fixed", fmt.Sprintf("%d",
txpower)}); err != nil {
if _, err := core.Exec("iw", []string{"dev", name, "set", "txpower", "fixed", fmt.Sprintf("%d", txpower)}); err != nil {
return err
}
} else if core.HasBinary("iwconfig") {
Expand Down

0 comments on commit dfe64ee

Please sign in to comment.