From c61b428d67a5219c68bb97a71e3575d2c402ca21 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:40:56 -0500 Subject: [PATCH] fix: panic when error occurs in commander check if commander has an error before trying to get a return code --- shell.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/shell.go b/shell.go index d04d4a0..06854fa 100644 --- a/shell.go +++ b/shell.go @@ -124,6 +124,13 @@ func execCommand(cmd string) error { NRet: 1, Protect: true, }, luacmdArgs) + + if err != nil { + fmt.Fprintln(os.Stderr, + "Error in command:\n\n" + err.Error()) + return interp.NewExitStatus(1) + } + luaexitcode := l.Get(-1) var exitcode uint8 = 0 @@ -133,10 +140,6 @@ func execCommand(cmd string) error { exitcode = uint8(code) } - if err != nil { - fmt.Fprintln(os.Stderr, - "Error in command:\n\n" + err.Error()) - } cmdFinish(exitcode, argstring) return interp.NewExitStatus(exitcode) }