From 13e6d180f8044b8d2357bd5e17c0b0a3000fa58c Mon Sep 17 00:00:00 2001 From: sammyette Date: Sat, 28 Dec 2024 19:50:06 -0400 Subject: [PATCH] fix: use global env variables when executing --- exec.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/exec.go b/exec.go index 357c143..7f8e37b 100644 --- a/exec.go +++ b/exec.go @@ -434,26 +434,8 @@ func execHandle(bg bool) interp.ExecHandlerFunc { // sh/interp but with our job handling env := hc.Env - envList := make([]string, 0, 64) + envList := os.Environ() env.Each(func(name string, vr expand.Variable) bool { - if name == "PATH" { - pathEnv := os.Getenv("PATH") - envList = append(envList, "PATH="+pathEnv) - return true - } - - if !vr.IsSet() { - // If a variable is set globally but unset in the - // runner, we need to ensure it's not part of the final - // list. Seems like zeroing the element is enough. - // This is a linear search, but this scenario should be - // rare, and the number of variables shouldn't be large. - for i, kv := range envList { - if strings.HasPrefix(kv, name+"=") { - envList[i] = "" - } - } - } if vr.Exported && vr.Kind == expand.String { envList = append(envList, name+"="+vr.String()) }