Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8761402

Browse files
committed
WIP
1 parent 4bae3e9 commit 8761402

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

agent/agent.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,14 +1406,20 @@ func expandDirectory(dir string) (string, error) {
14061406
return "", err
14071407
}
14081408
dir = filepath.Join(home, dir[1:])
1409-
} else if dir[0] != '/' {
1409+
1410+
} else if !filepath.IsAbs(dir) {
1411+
// If the directory is not absolute, we assume it is relative to the
1412+
// user's home directory.
14101413
home, err := userHomeDir()
14111414
if err != nil {
14121415
return "", err
14131416
}
14141417
dir = filepath.Join(home, dir)
1418+
14151419
} else {
1416-
return "", fmt.Errorf("not a valid directory")
1420+
// If the directory is absolute, we assume it is an absolute path.
1421+
// We do not check if the directory exists.
1422+
return dir, nil
14171423
}
14181424
return os.ExpandEnv(dir), nil
14191425
}

0 commit comments

Comments
 (0)