// envForDir returns a copy of the environment
// suitable for running in the given directory.
// The environment is the current process's environment
// but with an updated $PWD, so that an os.Getwd in the
// child will be faster.
347541
func envForDir(dir string) []string {
	env := os.Environ()
	// Internally we only use rooted paths, so dir is rooted.
	// Even if dir is not rooted, no harm done.
	return mergeEnvLists([]string{"PWD=" + dir}, env)
}
968399
func EnsureDir(fs utilfs.Filesystem, path string) error {
	// if dir exists, don't change it, but do report any unexpected errors
	if ok, err := DirExists(fs, path); ok || err != nil {
		return err
	} // Assert: dir does not exist

	// create the dir
	return fs.MkdirAll(path, defaultPerm)
}
790818
func (j *AuroraJob) Environment(env string) Job {
	j.jobConfig.Key.Environment = env
	return j
}
114784
func MustGetenv(key string) string {
	value := os.Getenv(key)
	if value == "" {
		panic("Missing key " + key)
	}

	return value
}
1256870
func getEnvString(v string, def string) string {
	r := os.Getenv(v)
	if r == "" {
		return def
	}

	return r
}
461480
func LoadEnvFromFile(envFile string) error {
	if envFile == "" {
		return nil
	}

	file, err := os.Open(envFile)
	if err != nil {
		return err
	}
	defer file.Close()

	envMap, err := ParseEnvFile(file)
	if err != nil {
		return err
	}

	for k, v := range envMap {
		if err := os.Setenv(k, v); err != nil {
			return err
		}
	}

	return nil
}
608596
func (e *Env) Interpreter() *python.Interpreter {
	if e.interpreter == nil {
		e.interpreter = &python.Interpreter{
			Python: e.Python,
		}
	}
	return e.interpreter
}
226985
func (d *Deployment) GetEnvironment() string {
	if d == nil || d.Environment == nil {
		return ""
	}
	return *d.Environment
}
608284
func (env *OsEnvReader) LookupEnv(key string) (string, bool) {
	return env.lookup(key)
}
356565
func (e *Env) Copy() *Env {
	e.Lock()
	defer e.Unlock()
	copy := Env{
		name:     e.name,
		env:      make(map[string]reflect.Value),
		typ:      make(map[string]reflect.Type),
		parent:   e.parent,
		external: e.external,
	}
	for name, value := range e.env {
		copy.env[name] = value
	}
	for name, typ := range e.typ {
		copy.typ[name] = typ
	}
	return &copy
}
378537
func setEnv(cmd *exec.Cmd, envs map[string]string) {
	env := os.Environ()
	cmd.Env = make([]string, 0, len(env)+len(envs))
outer:
	for _, e := range env {
		for k := range envs {
			if strings.HasPrefix(e, k+"=") {
				continue outer
			}
		}
		cmd.Env = append(cmd.Env, e)
	}
	for k, v := range envs {
		cmd.Env = append(cmd.Env, k+"="+v)
	}
}
1338826
func LookupEnv(ctx context.Context, key string) subcommands.EnvVar {
	e, _ := ctx.Value(&envKey).(subcommands.Env)
	return e[key]
}
195624
func EnvBool(envVar string, defaultValue bool) bool {
	return envBool(os.Getenv, envVar, defaultValue)
}
1082271
func GetEnvironment() Environment {
	v := strings.ToLower(os.Getenv(EnvVarName))
	for env, l := range EnvMap {
		for _, e := range l {
			if e == v {
				return env
			}
		}
	}
	return EnvUnknown
}
1223469
func (c *Command) AddEnvs(envs ...string) *Command {
	c.envs = append(c.envs, envs...)
	return c
}
347267
func Env(app *Manifest, process *Process) map[string]string {
	return merge(app.Env, process.Env)
}
204640
func Env(m map[string]string) (env []string) {
	for k, v := range m {
		env = append(env, fmt.Sprintf("%s=%s", k, v))
	}
	return
}