From e92b6e0fab4c6ecd3b52b002ca9b67bfb0bfa44a Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 15 Feb 2023 17:46:20 +0800 Subject: [PATCH] fix: don't override env --- pkg/runner/run_context.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index bfd090ce9ce..24acfe11fe9 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -186,9 +186,11 @@ func (rc *RunContext) startHostEnvironment() common.Executor { } } for _, env := range os.Environ() { - i := strings.Index(env, "=") - if i > 0 { - rc.Env[env[0:i]] = env[i+1:] + if k, v, ok := strings.Cut(env, "="); ok { + // don't override + if _, ok := rc.Env[k]; !ok { + rc.Env[k] = v + } } }