2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-01 19:23:24 +00:00

fix: panic when error occurs in commander

check if commander has an error before trying to get a return code
This commit is contained in:
TorchedSammy 2021-11-22 15:40:56 -05:00
parent af4c3885ae
commit c61b428d67
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

View File

@ -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)
}