Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-19
18:44 • Ticket [3183016fff] cd .. from link in Windows confuses Tcl status still Ope... artifact: 616cef19e5 user: serhiy.storchaka
18:44 • Ticket [3577801fff] Issue with file normalize on Linux with symlink wtih &quot... artifact: 36b590b922 user: serhiy.storchaka
18:37
Fix [3577801fff], [3570244fff], [3183016fff] and [3099612fff]: on Unix, [file normalize] and [cd ..]... leaf check-in: 854be12c0a user: serhiy.storchaka tags: normalize-dotdot-after-link
2011-09-12
02:01 • Ticket [3183016fff] cd .. from link in Windows confuses Tcl status still Ope... artifact: 1823a36aa2 user: guardus
01:10 • Ticket [3183016fff]: 4 changes artifact: daa9086a1b user: dgp
01:09 • Ticket [3183016fff]: 4 changes artifact: a2ed9ba29f user: dgp
2011-09-11
00:17 • Ticket [3183016fff]: 5 changes artifact: a8636f4950 user: guardus
2011-02-16
08:03 • Add attachment error.tcl to ticket [3183016fff] artifact: 3993ef5698 user: guardus
08:03 • Ticket [3183016fff] cd .. from link in Windows confuses Tcl status still Ope... artifact: 13478cfe66 user: guardus
01:03 • New ticket [3183016fff]. artifact: 9da9c5c59d user: guardus

cd .. from link in Windows confuses Tcl

Open3183016fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 45 days ago
Descriptionplain2011-02-16 01:03:24
OS: Windows XP SP3

Performing "cd .." from a link confuses Tcl.

To recreate:
  1. Create directory test1 and subdirectory test1/test2 and then create a link in test2 to test1.
  2. cd test1/test2/<link>
  3. cd ..
  4. pwd and glob reports as if in parent of test1, but "file exists" finds file in test2 and cd acts as if in test2.

See attached Tcl script.
Referenced by2
  • 36b590b922Ticket [3577801fff] Issue with [file normalize] on Linux with symlink wtih ".." status still Open with 4 other changes ticket2026-10-19 18:44:30
  • 854be12c0aFix [3577801fff], [3570244fff], [3183016fff] and [3099612fff]: on Unix, [file normalize] and [cd ..] used the target of a link literally when ".." followed it, so "..", "." or a trailing "/" in the target or a chain of links gave a wrong path. Normalize the target first, as realpath() does. On Windows, resolve ".." lexically, as the system does, so that [pwd], [glob] and native paths agree after [cd ..] from a junction or a symbolic link. Potential incompatibility on Windows: [file normalize junction/..] is now the parent of the junction, not of its target. check-in2026-10-19 18:37:17
guardusplain2011-02-16 08:03:24
File Added - 401787: error.tcl
guardusplain2011-09-11 00:17:59
Same issue in ActiveTcl 8.5.10.1.
dgpplain2011-09-12 01:09:38
Please review ticket 961646
and comment whether this is a
new issue distinct from that, or a
duplicate report of the same issue.
Thanks.
dgpplain2011-09-12 01:10:33
If you could also report whether any
release of Tcl since 8.4.0 met your
expectations on the same platform,
that would be useful info.
guardusplain2011-09-12 02:01:58
I could not find 961646, but I did find 849514, and this certainly seems to be similar to 849514.

I don't have 8.4 on my system.
serhiy.storchakawiki2026-10-19 18:44:30

Still present on Windows 11 with 8.5.19 to 9.1: after cd test1/test2/link; cd .. with a junction to test1, [pwd] and [glob] show the parent of test1, while [file exists], [open] and cmd /c cd use test2. Tcl resolves ".." physically after the link, but Windows itself resolves it lexically.

Proposed fix in branch normalize-dotdot-after-link: on Windows ".." is resolved lexically, as the system does (and as Python's ntpath.realpath() does), so all of them agree on test2; links elsewhere in the path are still resolved. This works for junctions and for mklink /D symbolic links, absolute or relative. Potential incompatibility: [file normalize junction/..] is now the parent of the junction, not of its target; filesystem-1.26 and 1.28 are changed accordingly. On Unix ".." stays physical, and a trailing ".." after a relative link is now resolved ([3577801fff]). Tests winFile-6.1, 6.2 and filesystem-1.57.

Log in (anonymous is fine) to add a comment.

Attachments: