fix: handle error before getting commander exit code

this fixes a register underflow issue if a commander causes an error
pull/69/head
sammyette 2021-06-14 18:02:44 -04:00
parent 36ea20b550
commit 30ffe9cab0
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 6 additions and 4 deletions

View File

@ -56,6 +56,12 @@ func RunInput(input string) {
NRet: 1,
Protect: true,
}, luar.New(l, cmdArgs[1:]))
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
hooks.Em.Emit("command.exit", 1)
return
}
luaexitcode := l.Get(-1)
var exitcode uint8 = 0
@ -65,10 +71,6 @@ func RunInput(input string) {
exitcode = uint8(code)
}
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
}
hooks.Em.Emit("command.exit", exitcode)
return
}