From 6db529e6ac171a534d5ff8127f9ef6de347f6cd4 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Wed, 23 Nov 2022 18:24:52 -0400 Subject: [PATCH 1/2] fix: reuse runner instance makes sure that env vars set in shell persist, among other things. --- exec.go | 2 -- main.go | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exec.go b/exec.go index caf7d1b..99e9d36 100644 --- a/exec.go +++ b/exec.go @@ -260,8 +260,6 @@ func execCommand(cmd string, terminalOut bool) (io.Writer, io.Writer, error) { return nil, nil, err } - runner, _ := interp.New() - var stdout io.Writer var stderr io.Writer if terminalOut { diff --git a/main.go b/main.go index ee0f584..5f0964b 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( "github.com/pborman/getopt" "github.com/maxlandon/readline" "golang.org/x/term" + "mvdan.cc/sh/v3/interp" ) var ( @@ -33,9 +34,11 @@ var ( hooks *bait.Bait defaultConfPath string defaultHistPath string + runner *interp.Runner ) func main() { + runner, _ = interp.New() curuser, _ = user.Current() homedir := curuser.HomeDir confDir, _ = os.UserConfigDir() From 22ebf1fa2353d7c2d2b095ddc491d6eeb20e79dc Mon Sep 17 00:00:00 2001 From: sammyette Date: Fri, 19 Jul 2024 09:54:50 -0400 Subject: [PATCH 2/2] fix: dont make new instance of interpreter --- exec.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/exec.go b/exec.go index cf1b299..9055fcf 100644 --- a/exec.go +++ b/exec.go @@ -269,8 +269,6 @@ func execCommand(cmd string, strms *streams) (io.Writer, io.Writer, error) { return nil, nil, err } - runner, _ := interp.New() - if strms == nil { strms = &streams{} }