fix(shell): split environment variable name and value correctly

This commit is contained in:
L. Yeung 2023-01-20 12:14:14 +08:00 committed by Jan De Dobbeleer
parent 9ec794cacf
commit 1a1aecbd36

View file

@ -724,13 +724,11 @@ func (env *Shell) TemplateCache() *TemplateCache {
const separator = "=" const separator = "="
values := os.Environ() values := os.Environ()
for value := range values { for value := range values {
splitted := strings.Split(values[value], separator) key, val, valid := strings.Cut(values[value], separator)
if len(splitted) != 2 { if !valid {
continue continue
} }
key := splitted[0] tmplCache.Env[key] = val
val := splitted[1:]
tmplCache.Env[key] = strings.Join(val, separator)
} }
pwd := env.Pwd() pwd := env.Pwd()
tmplCache.PWD = ReplaceHomeDirPrefixWithTilde(env, pwd) tmplCache.PWD = ReplaceHomeDirPrefixWithTilde(env, pwd)