mirror of https://github.com/Hilbis/Hilbish
fix: cleanup and move exit command to lua side
parent
ef4975f984
commit
807ec15faa
|
@ -26,6 +26,10 @@ commander.register('cd', function (args)
|
|||
bait.throw('command.success', nil)
|
||||
end)
|
||||
|
||||
commander.register('exit', function()
|
||||
os.exit(0)
|
||||
end)
|
||||
|
||||
do
|
||||
local virt_G = { }
|
||||
|
||||
|
|
14
shell.go
14
shell.go
|
@ -47,19 +47,15 @@ func RunInput(input string) {
|
|||
Protect: true,
|
||||
}, luar.New(l, cmdArgs[1:]))
|
||||
if err != nil {
|
||||
// TODO: dont panic
|
||||
panic(err)
|
||||
fmt.Fprintln(os.Stderr,
|
||||
"Error in command:\n\n" + err.Error())
|
||||
}
|
||||
HandleHistory(cmdString)
|
||||
if cmdArgs[0] != "exit" { HandleHistory(cmdString) }
|
||||
return
|
||||
}
|
||||
|
||||
// Last option: use sh interpreter
|
||||
switch cmdArgs[0] {
|
||||
case "exit":
|
||||
os.Exit(0)
|
||||
default:
|
||||
err := execCommand(cmdString)
|
||||
err = execCommand(cmdString)
|
||||
if err != nil {
|
||||
// If input is incomplete, start multiline prompting
|
||||
if syntax.IsIncomplete(err) {
|
||||
|
@ -67,7 +63,6 @@ func RunInput(input string) {
|
|||
cmdString, err = ContinuePrompt(strings.TrimSuffix(cmdString, "\\"))
|
||||
if err != nil { break }
|
||||
err = execCommand(cmdString)
|
||||
|
||||
if syntax.IsIncomplete(err) || strings.HasSuffix(input, "\\") {
|
||||
continue
|
||||
} else if code, ok := interp.IsExitStatus(err); ok {
|
||||
|
@ -87,7 +82,6 @@ func RunInput(input string) {
|
|||
bait.Em.Emit("command.exit", 0)
|
||||
}
|
||||
HandleHistory(cmdString)
|
||||
}
|
||||
}
|
||||
|
||||
// Run command in sh interpreter
|
||||
|
|
Loading…
Reference in New Issue