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 isRoot(name string) bool { return filepath.Dir(name) == name }
|
||||||
|
|
||||||
func replaceTilde(s string) string {
|
func replaceTilde(s string) string {
|
||||||
if strings.HasPrefix(s, "~") {
|
if rest, ok := strings.CutPrefix(s, "~"); ok && (rest == "" || os.IsPathSeparator(rest[0])) {
|
||||||
return gUser.HomeDir + s[1:]
|
return gUser.HomeDir + rest
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user