github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/env/env_windows.go (about)

     1  package env
     2  
     3  // ParseSlice parses the specified slice and transforms it into an environment
     4  // map.
     5  func ParseSlice(s []string) (map[string]string, error) {
     6  	env := make(map[string]string, len(s))
     7  	for _, e := range s {
     8  		if 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 conlficting 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.
    17  			continue
    18  		}
    19  
    20  		if err := parseEnv(env, e); err != nil {
    21  			return nil, err
    22  		}
    23  	}
    24  	return env, nil
    25  }