mirror of https://github.com/Hilbis/Hilbish
fix!: pass non expanded input to builtin runners
fixes an issue with expanded aliases being added to history with a recent commit (6th time now with this issue?) and makes behavior with other runners consistent this can technically be a breaking change to people overriding the sh runner functionpull/207/head
parent
8647dc57a1
commit
e5c8e5eaff
15
exec.go
15
exec.go
|
@ -96,23 +96,23 @@ func runInput(input string, priv bool) {
|
||||||
if currentRunner.Type() == rt.StringType {
|
if currentRunner.Type() == rt.StringType {
|
||||||
switch currentRunner.AsString() {
|
switch currentRunner.AsString() {
|
||||||
case "hybrid":
|
case "hybrid":
|
||||||
_, _, err = handleLua(cmdString)
|
_, _, err = handleLua(input)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmdFinish(0, input, priv)
|
cmdFinish(0, input, priv)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
input, exitCode, cont, err = handleSh(cmdString)
|
input, exitCode, cont, err = handleSh(input)
|
||||||
case "hybridRev":
|
case "hybridRev":
|
||||||
_, _, _, err = handleSh(input)
|
_, _, _, err = handleSh(input)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmdFinish(0, input, priv)
|
cmdFinish(0, input, priv)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
input, exitCode, err = handleLua(cmdString)
|
input, exitCode, err = handleLua(input)
|
||||||
case "lua":
|
case "lua":
|
||||||
input, exitCode, err = handleLua(cmdString)
|
input, exitCode, err = handleLua(input)
|
||||||
case "sh":
|
case "sh":
|
||||||
input, exitCode, cont, err = handleSh(cmdString)
|
input, exitCode, cont, err = handleSh(input)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// can only be a string or function so
|
// can only be a string or function so
|
||||||
|
@ -130,7 +130,7 @@ func runInput(input string, priv bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cont {
|
if cont {
|
||||||
cmdString, err = reprompt(input)
|
input, err = reprompt(input)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
goto rerun
|
goto rerun
|
||||||
} else if err == io.EOF {
|
} else if err == io.EOF {
|
||||||
|
@ -195,7 +195,8 @@ func runLuaRunner(runr rt.Value, userInput string) (input string, exitCode uint8
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleLua(cmdString string) (string, uint8, error) {
|
func handleLua(input string) (string, uint8, error) {
|
||||||
|
cmdString := aliases.Resolve(input)
|
||||||
// First try to load input, essentially compiling to bytecode
|
// First try to load input, essentially compiling to bytecode
|
||||||
chunk, err := l.CompileAndLoadLuaChunk("", []byte(cmdString), rt.TableValue(l.GlobalEnv()))
|
chunk, err := l.CompileAndLoadLuaChunk("", []byte(cmdString), rt.TableValue(l.GlobalEnv()))
|
||||||
if err != nil && noexecute {
|
if err != nil && noexecute {
|
||||||
|
|
|
@ -28,13 +28,13 @@ func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
input, exitCode, cont, err := execSh(cmd)
|
_, exitCode, cont, err := execSh(aliases.Resolve(cmd))
|
||||||
var luaErr rt.Value = rt.NilValue
|
var luaErr rt.Value = rt.NilValue
|
||||||
if err != nil {
|
if err != nil {
|
||||||
luaErr = rt.StringValue(err.Error())
|
luaErr = rt.StringValue(err.Error())
|
||||||
}
|
}
|
||||||
runnerRet := rt.NewTable()
|
runnerRet := rt.NewTable()
|
||||||
runnerRet.Set(rt.StringValue("input"), rt.StringValue(input))
|
runnerRet.Set(rt.StringValue("input"), rt.StringValue(cmd))
|
||||||
runnerRet.Set(rt.StringValue("exitCode"), rt.IntValue(int64(exitCode)))
|
runnerRet.Set(rt.StringValue("exitCode"), rt.IntValue(int64(exitCode)))
|
||||||
runnerRet.Set(rt.StringValue("continue"), rt.BoolValue(cont))
|
runnerRet.Set(rt.StringValue("continue"), rt.BoolValue(cont))
|
||||||
runnerRet.Set(rt.StringValue("err"), luaErr)
|
runnerRet.Set(rt.StringValue("err"), luaErr)
|
||||||
|
|
Loading…
Reference in New Issue