| Ticket UUID: | 82049f96f841214bb8cee18e1bf8f84aa25ed9aa | ||
| Title: | file copy attempts to copy directory into itself | ||
| Type: | Bug | Created on: | 2018-11-21 14:06:54 |
| Submitter: | anonymous | Assigned to: | nobody |
| Subsystem: | 37. File System | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-10-21 18:29:26 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
Tcl's "file copy" functionality attempts to copy a directory into itself. Like: $ mkdir 1 $ mkdir 1/2 $ tclsh % file copy 1 1/2 error copying "1" to "1/2/1": "1/2/1/2/1/2[long string deleted]": file name too long Other, similar programs seem to check the inodes of the path to ensure directories don't get copied into themselves: $ mkdir 1 $ mkdir 1/2 $ cp -r 1 1/2 cp: cannot copy a directory, '1', into itself, '1/2/1' | ||||
| User Comments: | ||||
serhiy.storchaka added on 2026-10-17 10:53:34:
The deep tree that [file copy 1 1/2] leaves behind cannot be removed with [file delete -force] either: [daba77ae1d]. serhiy.storchaka added on 2026-10-19 18:54:12:
Still present in 8.6, 9.0 and 9.1: [file copy 1 1/2] (and [file copy -force d d]) copies until the path is too long, and leaves a tree that [file delete -force] cannot remove ([daba77ae1d]). Proposed fix in branch copy-into-itself, together with [875545270d]: copying a directory into itself is now an error, "trying to copy a directory into itself". The normalized paths are compared, so links are handled, and so is a different letter case on Windows (checked under Wine). If the target's parent does not exist, the old error is kept. Tests fCmd-21.13 and 21.14. dgp added on 2026-10-21 18:29:26:
Just want to add a caution that Tcl's virtual filesystems and ability to mount anywhere undermines a lot of "common sense" reasoning about the relationship between directories. Be sure to consider all the possibilities and not limit your analysis to the assumption that all paths are inside a single filesystem. | ||||
