fix tilde expansion on file operations (#2687)
This commit is contained in:
1 parent
df5f71c523
commit
5d3c7b7025
1 file changed
+2
-2
@@ -32,8 +32,8 @@ var (
|
||||
func isRoot(name string) bool { return filepath.Dir(name) == name }
|
||||
|
||||
func replaceTilde(s string) string {
|
||||
if strings.HasPrefix(s, "~") {
|
||||
return gUser.HomeDir + s[1:]
|
||||
if rest, ok := strings.CutPrefix(s, "~"); ok && (rest == "" || os.IsPathSeparator(rest[0])) {
|
||||
return gUser.HomeDir + rest
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user