| Ticket UUID: | 1827008 | ||
| Title: | delete and copy fail in linux when path contains ".." | ||
| Type: | Bug | Created on: | 2007-11-06 17:15:50 |
| Submitter: | mgma | Assigned to: | vincentdarley |
| Subsystem: | 37. File System | Severity: | |
| Priority: | 5 Medium | Last modified: | 2026-10-17 09:08:45 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
The code below runs correctly in Windows, but not in Linux. (I'm using ActiveTcl 8.4.7 in both cases). % file mkdir d1/d2/d3 % file delete -force d1/d2/d3/.. In Windows, it deletes d2 and leaves d1 empty. However, in Linux I get the error: 'error deleting "d1/d2/d3/..": no such file or directory In Linux, d3 is deleted, but not d2. In order that it works I must normalize the file name: % file delete -force [file normalize d1/d2/d3/..] I think that it might not be correct that the operation is partially performed and then fails. I also find the error message not very descriptive of the problem. The same thing happens when using [file copy] with directory paths containing "..". I've asked about this at comp.lang.tcl, and Donald G Porter suggested that it may be the same as Bug 961646. | ||||
| User Comments: | ||||
serhiy.storchaka added on 2026-10-17 09:08:45:
Still there, and since 8.5 the failure is silent: [file delete -force d1/d2/d3/..] deletes the contents of d2 but not d2 itself, and returns success (the final rmdir() fails with ENOENT, which is ignored). Proposed fix in branch delete-refuse-dot-dot: on Unix, refuse to remove a path ending in "." or "..", as rm(1) does. Normalizing the path, as on Windows, would be wrong on POSIX: ".." is resolved physically there, so if d3 is a symbolic link, "d1/d2/d3/.." is the parent of its target, not "d1/d2". Test fCmd-5.14. | ||||
