fix tilde expansion on file operations (#2687)

This commit is contained in:
valoq authored and GitHub committed 2026-10-09 23:15:45 +02:00
1 parent df5f71c523
commit 5d3c7b7025
1 file changed
+2 -2
+2 -2
View File
@@ -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
}