File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1406,14 +1406,20 @@ func expandDirectory(dir string) (string, error) {
1406
1406
return "" , err
1407
1407
}
1408
1408
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.
1410
1413
home , err := userHomeDir ()
1411
1414
if err != nil {
1412
1415
return "" , err
1413
1416
}
1414
1417
dir = filepath .Join (home , dir )
1418
+
1415
1419
} 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
1417
1423
}
1418
1424
return os .ExpandEnv (dir ), nil
1419
1425
}
You can’t perform that action at this time.
0 commit comments