podman
1package env
2
3// ParseSlice parses the specified slice and transforms it into an environment
4// map.
5func ParseSlice(s []string) (map[string]string, error) {
6env := make(map[string]string, len(s))
7for _, e := range s {
8if len(e) > 0 && e[0] == '=' {
9// The legacy Windows CMD command interpreter uses a hack, where to emulate
10// DOS semantics, it uses an illegal (by windows definition) env name for
11// state storage to avoid conflicting with user defined env names. This is
12// used to preserve drive letter paths. E.g., typing c: from another drive
13// will remember the last CWD because CMD stores it in an env named "=C:".
14// Since these are illegal, they are filtered from standard user access but
15// are still available in the underlying win32 API calls. Since they have
16// zero value to a container, we filter as well.
17continue
18}
19
20if err := parseEnv(env, e); err != nil {
21return nil, err
22}
23}
24return env, nil
25}
26