jsonconfig: special-case USER env var expansion on Windows

Change-Id: I7ff6c68417f901a7e7e41da1e2bf23be6e94cfa1
This commit is contained in:
Brad Fitzpatrick 2013-08-28 12:27:09 -07:00
parent 3c3009a270
commit 07e11f66a7
1 changed files with 5 additions and 0 deletions

View File

@ -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