From c96605e79c85ee62b56ddf20be87d0b8dc7d96a8 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Tue, 30 Aug 2022 23:07:24 -0400 Subject: [PATCH] feat: allow hilbish.runner.sh to be overridden --- exec.go | 12 +++++++++++- runnermode.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/exec.go b/exec.go index dcf8845..26c0b73 100644 --- a/exec.go +++ b/exec.go @@ -221,7 +221,17 @@ func handleLua(cmdString string) (string, uint8, error) { return cmdString, 125, err } -func handleSh(cmdString string) (string, uint8, bool, error) { +func handleSh(cmdString string) (input string, exitCode uint8, cont bool, runErr error) { + shRunner := hshMod.Get(rt.StringValue("runner")).AsTable().Get(rt.StringValue("sh")) + var err error + input, exitCode, cont, runErr, err = runLuaRunner(shRunner, cmdString) + if err != nil { + runErr = err + } + return +} + +func execSh(cmdString string) (string, uint8, bool, error) { _, _, err := execCommand(cmdString, true) if err != nil { // If input is incomplete, start multiline prompting diff --git a/runnermode.go b/runnermode.go index eca33ba..b8995cd 100644 --- a/runnermode.go +++ b/runnermode.go @@ -28,7 +28,7 @@ func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { return nil, err } - input, exitCode, cont, err := handleSh(cmd) + input, exitCode, cont, err := execSh(cmd) var luaErr rt.Value = rt.NilValue if err != nil { luaErr = rt.StringValue(err.Error())