mirror of
https://codeberg.org/frosty/modbot.git
synced 2024-09-19 03:36:35 -04:00
add some checks for whether exec cmd exits non-0 or output is blank
This commit is contained in:
parent
fe651bdf28
commit
79a40f82f5
|
@ -18,6 +18,7 @@ package readers
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
@ -36,6 +37,10 @@ func readExec(command string) (interface{}, error) {
|
|||
return ExecInfo(""), err
|
||||
}
|
||||
|
||||
if cmd.ProcessState.ExitCode() != 0 {
|
||||
return ExecInfo(""), errors.New("returned non-zero exit code")
|
||||
}
|
||||
|
||||
outputLines := strings.Split(stdout.String(), "\n")
|
||||
if len(outputLines) == 0 {
|
||||
return ExecInfo(""), nil
|
||||
|
|
Loading…
Reference in a new issue