X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fcommon%2Ffilepath.go;h=d9cb3d55bf27d879edc43f6841d7e916a7e5e7c7;hb=59b0682f87803e69a58e58ea0f3c50f606745cae;hp=4c8c0da5487f60a02b9fa46eccb3276f37d96f1b;hpb=96fae3e86cc98b3cca4e96c002a92d98f05eb5b7;p=src%2Fxds%2Fxds-agent.git diff --git a/lib/common/filepath.go b/lib/common/filepath.go index 4c8c0da..d9cb3d5 100644 --- a/lib/common/filepath.go +++ b/lib/common/filepath.go @@ -7,6 +7,7 @@ import ( "path" "path/filepath" "regexp" + "runtime" ) // Exists returns whether the given file or directory exists or not @@ -42,7 +43,14 @@ func ResolveEnvVar(s string) (string, error) { for _, v := range vars { val := os.Getenv(v[1]) if val == "" { - return res, fmt.Errorf("ERROR: %s env variable not defined", v[1]) + // Specific case to resolved $HOME or ${HOME} on Windows host + if runtime.GOOS == "windows" && v[1] == "HOME" { + if usr, err := user.Current(); err == nil { + val = usr.HomeDir + } + } else { + return res, fmt.Errorf("ERROR: %s env variable not defined", v[1]) + } } rer := regexp.MustCompile("\\${" + v[1] + "}")