X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fcommon%2Ffilepath.go;h=4c8c0da5487f60a02b9fa46eccb3276f37d96f1b;hb=2ad72d9ee3aafb2426b28a86b505da9d24f3e768;hp=42ef82f31e6697576d77707f1778b71a6e2731e9;hpb=199bec04165a8bd8d52034963725a2c6161814af;p=src%2Fxds%2Fxds-server.git diff --git a/lib/common/filepath.go b/lib/common/filepath.go index 42ef82f..4c8c0da 100644 --- a/lib/common/filepath.go +++ b/lib/common/filepath.go @@ -24,9 +24,12 @@ func Exists(path string) bool { // ResolveEnvVar Resolved environment variable regarding the syntax ${MYVAR} // or $MYVAR following by a slash or a backslash func ResolveEnvVar(s string) (string, error) { + if s == "" { + return s, nil + } // Resolved tilde : ~/ - if s[:2] == "~/" { + if len(s) > 2 && s[:2] == "~/" { if usr, err := user.Current(); err == nil { s = filepath.Join(usr.HomeDir, s[2:]) }