diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 16:47:58 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 16:47:58 +0200 |
commit | 96fae3e86cc98b3cca4e96c002a92d98f05eb5b7 (patch) | |
tree | be8e462bbb95bed2f3bd0aaa0f3186e733ae2da8 /lib/common | |
parent | ec56178fa1a7b260afe3d818c6b14a432613ad44 (diff) |
Fix ResolveEnvVar when path is not set.
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/filepath.go | 5 |
1 files changed, 4 insertions, 1 deletions
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:]) } |