// EnvBool returns a bool from an environment variable or default if invalid or
// not specified
195624
func EnvBool(envVar string, defaultValue bool) bool {
	return envBool(os.Getenv, envVar, defaultValue)
}
112896
func env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
921784
func (b *Builder) SetHookEnv(hook string, envs map[string]string) *Builder {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.setHookEnvLocked(hook, envs)
}
563304
func environ() (env []string) {
	for _, v := range os.Environ() {
		if !strings.HasPrefix(v, "GOPATH=") {
			env = append(env, v)
		}
	}
	env = append(env, "GOPATH="+gopath)
	return
}
536699
func ExportEnv(env []string) string {
	if len(env) == 0 {
		return ""
	}
	out := "export"
	for _, e := range env {
		if len(e) == 0 {
			continue
		}
		out += " " + BashQuote(e)
	}
	return out + "; "
}
267811
func (enc *Encoder) encodeBool(v bool) ([]byte, error) {
	enc.grow(5)
	if v {
		enc.writeString("true")
	} else {
		enc.writeString("false")
	}
	return enc.buf, enc.err
}
248609
func Bool(key string, def bool) bool {
	val := os.Getenv(key)
	if val == "" {
		return def
	}

	b, err := strconv.ParseBool(val)
	if err != nil {
		return def
	}
	return b
}
363193
func RevokableSetenv(envKey, envValue string) (func() error, error) {
	origValue := os.Getenv(envKey)
	revokeFn := func() error {
		return os.Setenv(envKey, origValue)
	}

	return revokeFn, os.Setenv(envKey, envValue)
}
328233
func EvalBool(expr Expression, row []types.Datum, ctx context.Context) (bool, error) {
	data, err := expr.Eval(row, ctx)
	if err != nil {
		return false, errors.Trace(err)
	}
	if data.IsNull() {
		return false, nil
	}

	i, err := data.ToBool(ctx.GetSessionVars().StmtCtx)
	if err != nil {
		return false, errors.Trace(err)
	}
	return i != 0, nil
}
338461
func getEnvBool(v string, def bool) bool {
	r := os.Getenv(v)
	if r == "" {
		return def
	}

	switch strings.ToLower(r[0:1]) {
	case "t", "y", "1":
		return true
	}

	return false
}
395091
func (r *Application) AddEnv(name, value string) *Application {
	if r.Env == nil {
		r.EmptyEnvs()
	}
	(*r.Env)[name] = value

	return r
}
868186
func Bootstrap() (Env, error) {
	file, err := os.Open(".env")
	if err != nil {
		return nil, err
	}

	return Load(file)
}
450716
func GetOrDefaultBool(envVar string, defaultValue bool) bool {
	v, err := strconv.ParseBool(GetOrFile(envVar))
	if err != nil {
		return defaultValue
	}

	return v
}
94403
func Env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
976283
func envOr(name, def string) string {
	s := os.Getenv(name)
	if s == "" {
		return def
	}
	return s
}
76031
func (e *Environment) Bool(name string) (bool, error) {
	v, err := e.value(name)
	if err != nil {
		return false, err
	}

	return strconv.ParseBool(v)
}
717723
func ConvertEnvironmentToDocker(env api.EnvironmentList) (result string) {
	for i, e := range env {
		if i == 0 {
			result += fmt.Sprintf("ENV %s=\"%s\"", e.Name, e.Value)
		} else {
			result += fmt.Sprintf(" \\\n    %s=\"%s\"", e.Name, e.Value)
		}
	}
	result += "\n"
	return
}