fix: deregister commander if return isnt number

lua5.4
TorchedSammy 2022-04-02 12:33:08 -04:00
parent 0826839846
commit b39083fe32
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 6 additions and 3 deletions

View File

@ -192,8 +192,7 @@ func execCommand(cmd string, terminalOut bool) (io.Writer, io.Writer, error) {
if commands[args[0]] != nil {
luaexitcode, err := rt.Call1(l.MainThread(), rt.FunctionValue(commands[args[0]]), rt.TableValue(luacmdArgs))
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
fmt.Fprintln(os.Stderr, "Error in command:\n\n" + err.Error())
return interp.NewExitStatus(1)
}
@ -201,7 +200,11 @@ func execCommand(cmd string, terminalOut bool) (io.Writer, io.Writer, error) {
if code, ok := luaexitcode.TryInt(); ok {
exitcode = uint8(code)
} // TODO: deregister commander if return isnt number
} else if luaexitcode != rt.NilValue {
// deregister commander
delete(commands, args[0])
fmt.Fprintf(os.Stderr, "Commander did not return number for exit code. %s, you're fired.\n", args[0])
}
return interp.NewExitStatus(exitcode)
}