fix: add platform to OS on linux

resolves #1639
This commit is contained in:
Jan De Dobbeleer 2022-02-03 11:42:31 +01:00 committed by Jan De Dobbeleer
parent 6e91805aa7
commit e545b32896

View file

@ -599,13 +599,13 @@ func (env *ShellEnvironment) TemplateCache() *TemplateCache {
if env.tmplCache != nil { if env.tmplCache != nil {
return env.tmplCache return env.tmplCache
} }
tmplCache := &TemplateCache{ env.tmplCache = &TemplateCache{
Root: env.Root(), Root: env.Root(),
Shell: env.Shell(), Shell: env.Shell(),
Code: env.ErrorCode(), Code: env.ErrorCode(),
WSL: env.IsWsl(), WSL: env.IsWsl(),
} }
tmplCache.Env = make(map[string]string) env.tmplCache.Env = make(map[string]string)
const separator = "=" const separator = "="
values := os.Environ() values := os.Environ()
for value := range values { for value := range values {
@ -615,19 +615,21 @@ func (env *ShellEnvironment) TemplateCache() *TemplateCache {
} }
key := splitted[0] key := splitted[0]
val := splitted[1:] val := splitted[1:]
tmplCache.Env[key] = strings.Join(val, separator) env.tmplCache.Env[key] = strings.Join(val, separator)
} }
pwd := env.Pwd() pwd := env.Pwd()
pwd = strings.Replace(pwd, env.Home(), "~", 1) pwd = strings.Replace(pwd, env.Home(), "~", 1)
tmplCache.PWD = pwd env.tmplCache.PWD = pwd
tmplCache.Folder = Base(env, pwd) env.tmplCache.Folder = Base(env, pwd)
tmplCache.UserName = env.User() env.tmplCache.UserName = env.User()
if host, err := env.Host(); err == nil { if host, err := env.Host(); err == nil {
tmplCache.HostName = host env.tmplCache.HostName = host
} }
goos := env.GOOS() goos := env.GOOS()
tmplCache.OS = goos env.tmplCache.OS = goos
env.tmplCache = tmplCache if goos == LinuxPlatform {
env.tmplCache.OS = env.Platform()
}
return env.tmplCache return env.tmplCache
} }