mirror of https://github.com/perkeep/perkeep.git
jsonconfig: special-case USER env var expansion on Windows
Change-Id: I7ff6c68417f901a7e7e41da1e2bf23be6e94cfa1
This commit is contained in:
parent
3c3009a270
commit
07e11f66a7
|
@ -24,6 +24,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"camlistore.org/pkg/errorutil"
|
||||
|
@ -222,6 +223,10 @@ func (c *ConfigParser) expandEnv(v []interface{}) (interface{}, error) {
|
|||
expanded := envPattern.ReplaceAllStringFunc(s, func(match string) string {
|
||||
envVar := match[2 : len(match)-1]
|
||||
val := os.Getenv(envVar)
|
||||
// Special case:
|
||||
if val == "" && envVar == "USER" && runtime.GOOS == "windows" {
|
||||
val = os.Getenv("USERNAME")
|
||||
}
|
||||
if val == "" {
|
||||
if hasDefault {
|
||||
return def
|
||||
|
|
Loading…
Reference in New Issue