diff --git a/exec.go b/exec.go index ff4ace2..0e08cd5 100644 --- a/exec.go +++ b/exec.go @@ -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) }