This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 773d97c070ccbc2541feb0ebcd9374cb87d02f87 Author: Christopher Collins <[email protected]> AuthorDate: Fri Sep 20 14:19:44 2019 -0500 util: interactive shell: error on nonzero exit Prior to this change, ShellInteractiveCommand() would never return an error. Now, this function returns an error if the specified command exits with a nonzero status. This change makes the function consistent with the other "shell command" functions in the util package. --- util/util.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/util/util.go b/util/util.go index 6b59fe7..a008a2e 100644 --- a/util/util.go +++ b/util/util.go @@ -405,12 +405,18 @@ func ShellInteractiveCommand(cmdStr []string, env []string, flagBlock bool) erro } // Release and exit - _, err = proc.Wait() + state, err := proc.Wait() + signal.Stop(c) + if err != nil { - signal.Stop(c) return NewNewtError(err.Error()) } - signal.Stop(c) + if state.ExitCode() != 0 { + return FmtNewtError( + "command %v exited with nonzero status %d", + cmdStr, state.ExitCode()) + } + return nil }
