forked from coop-cloud-mirrors/godotenv
Re-add global env variable substitution (#227)
Co-authored-by: Stanislau Arsoba <sarsoba@klika-tech.com>
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
@ -264,6 +265,12 @@ func expandVariables(v string, m map[string]string) string {
|
||||
if submatch[1] == "\\" || submatch[2] == "(" {
|
||||
return submatch[0][1:]
|
||||
} else if submatch[4] != "" {
|
||||
if val, ok := m[submatch[4]]; ok {
|
||||
return val
|
||||
}
|
||||
if val, ok := os.LookupEnv(submatch[4]); ok {
|
||||
return val
|
||||
}
|
||||
return m[submatch[4]]
|
||||
}
|
||||
return s
|
||||
|
Reference in New Issue
Block a user