mirror of https://github.com/Hilbis/Hilbish
fix: deregister commander if return isnt number
parent
0826839846
commit
b39083fe32
9
exec.go
9
exec.go
|
@ -192,8 +192,7 @@ func execCommand(cmd string, terminalOut bool) (io.Writer, io.Writer, error) {
|
||||||
if commands[args[0]] != nil {
|
if commands[args[0]] != nil {
|
||||||
luaexitcode, err := rt.Call1(l.MainThread(), rt.FunctionValue(commands[args[0]]), rt.TableValue(luacmdArgs))
|
luaexitcode, err := rt.Call1(l.MainThread(), rt.FunctionValue(commands[args[0]]), rt.TableValue(luacmdArgs))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprintln(os.Stderr, "Error in command:\n\n" + err.Error())
|
||||||
"Error in command:\n\n" + err.Error())
|
|
||||||
return interp.NewExitStatus(1)
|
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 {
|
if code, ok := luaexitcode.TryInt(); ok {
|
||||||
exitcode = uint8(code)
|
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)
|
return interp.NewExitStatus(exitcode)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue