diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 12:25:20 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 12:25:50 +0200 |
commit | 2ad72d9ee3aafb2426b28a86b505da9d24f3e768 (patch) | |
tree | ddf74c50a102de88f102599f8a12d4ee863660b5 /lib/common | |
parent | 199bec04165a8bd8d52034963725a2c6161814af (diff) |
Fix ResolveEnvVar when param is empty.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
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:]) } |