Skip to content

Commit

Permalink
fix: use LookupEnv to check if envar is actually set
Browse files Browse the repository at this point in the history
Fixes #389
  • Loading branch information
alecthomas committed Nov 13, 2023
1 parent 2df7678 commit 0ecd272
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ func (v *Value) Reset() error {
v.Target.Set(reflect.Zero(v.Target.Type()))
if len(v.Tag.Envs) != 0 {
for _, env := range v.Tag.Envs {
envar := os.Getenv(env)
envar, ok := os.LookupEnv(env)
// Parse the first non-empty ENV in the list
if envar != "" {
if ok {
err := v.Parse(ScanFromTokens(Token{Type: FlagValueToken, Value: envar}), v.Target)
if err != nil {
return fmt.Errorf("%s (from envar %s=%q)", err, env, envar)
Expand Down

0 comments on commit 0ecd272

Please sign in to comment.