Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-19
18:44 • Ticket [3099612fff] false, shortcut string /../ simplification everywhere, all f... artifact: 6cc8a2a60c 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
2010-11-01
20:36 • Ticket [3099612fff] false, shortcut string /../ simplification everywhere, all f... artifact: 6f7cef3551 user: dgp
2010-10-31
06:15 • New ticket [3099612fff]. artifact: 06329ae3b7 user: sto6

false, shortcut string /../ simplification everywhere, all f

Open3099612fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 44 days ago
Descriptionplain2010-10-31 06:15:59
What someone called 'lexical treatment of /../' in paths,
was subject of bug 961646: [file normalize] changes file reference

Much worse, 8.4.x does false, shortcut string /../ simplification EVERYWHERE,
full-time for ALL access to files (i.e. not limited to file normalize).
8.4.x does not resolve symlinks ahead of the /../, before applying the '..'.

$ ls -ld /etc/httpd/run
lrwxrwxrwx 1 root root 13 Feb 24  2010 /etc/httpd/run -> ../../var/run

$ tclsh8.4
% file stat /etc/httpd/run/../tmp/. ary; puts $ary(ino)
could not read "/etc/httpd/run/../tmp/.": no such file or directory

(incorrectly stats /etc/httpd/tmp, ignoring that run is symlink, not a true dir)

$ tclsh8.5
% file stat /etc/httpd/run/../tmp/. ary; puts $ary(ino)
3746244

$ ls -id /etc/httpd/run/../tmp/.
3746244 /etc/httpd/run/../tmp/.

Some shells (e.g. bash) offer choice of logical versus physical symlink resolution
in the 'cd' command. Except for such specialized flexibility (a CHOICE to change dir
relative to a symlink-unresolved path) it is never correct to do this full-time
for all file access.

right: 8.3.3, Solaris8
right: 8.3.5, Linux RedHat EL3U6
WRONG: 8.4.2, Solaris8
WRONG: 8.4.13, Linux Centos5.2
WRONG: 8.4.19, Linux Centos5.2, ActiveTcl 8.4.19 32bit
right: 8.5.7, Mac-OS-X 10.6.4
right: 8.5.9, Linux Centos5.2, ActiveTcl 8.5.9 32bit

So no bug in 8.3.x, bug in 8.4.x, and no bug in 8.5.x.

How could this have plagued essentially all of 8.4.x?
Now fixed again, was it deliberately targeted (what bug#)?

Or is appearance, disappearance of this bug merely side-effect of
dozens of other bug fixes, at risk to return again in 8.5 or later
as the wind blows? ;)
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
dgpplain2010-11-01 20:36:23
Please find a test in the test suite
that tests this matter.  If one does not
exist, please provide one we can add.
serhiy.storchakawiki2026-10-19 18:44:31

This works correctly since 8.5 (the link is resolved before ".."), and [file normalize] is covered by filesystem-1.26 to 1.28. As asked, branch normalize-dotdot-after-link adds test filesystem-1.58 for [file stat] and [file exists] through a relative link and "..". The ticket can be closed when it is merged.

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