fix: panic when error occurs in commander

check if commander has an error before trying to get a return code
dev
TorchedSammy 2021-11-22 15:40:56 -05:00
parent af4c3885ae
commit c61b428d67
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 7 additions and 4 deletions

View File

@ -124,6 +124,13 @@ func execCommand(cmd string) error {
NRet: 1, NRet: 1,
Protect: true, Protect: true,
}, luacmdArgs) }, luacmdArgs)
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
return interp.NewExitStatus(1)
}
luaexitcode := l.Get(-1) luaexitcode := l.Get(-1)
var exitcode uint8 = 0 var exitcode uint8 = 0
@ -133,10 +140,6 @@ func execCommand(cmd string) error {
exitcode = uint8(code) exitcode = uint8(code)
} }
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
}
cmdFinish(exitcode, argstring) cmdFinish(exitcode, argstring)
return interp.NewExitStatus(exitcode) return interp.NewExitStatus(exitcode)
} }