Tcl Source Code

View Ticket
Login
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 [3570244fff] "cd .." behaves wrong if last element in pwd is a ... artifact: 7c2e96e549 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
2012-10-17
19:31 • Ticket [3577801fff] Issue with file normalize on Linux with symlink wtih &quot... artifact: 3ceff08624 user: dgp
18:50 • Ticket [3577801fff]: 4 changes artifact: f60a183cd5 user: zoro2
09:28 • New ticket [3577801fff]. artifact: 335faa2c25 user: zoro2

Ticket UUID: 3577801
Title: Issue with [file normalize] on Linux with symlink wtih ".."
Type: Bug Created on: 2012-10-17 09:28:35
Submitter: zoro2 Assigned to: dgp
Subsystem: 37. File System Severity:
Priority: 5 Medium Last modified: 2026-10-19 18:44:30
Status: Open Closed by:
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:
Happend using latest Tcl 8.6b3 and 8.5.12. Code to reproduce (on Ubuntu Linux, ext3, but I doubt it matters).

set d [file join [file dirname [info script]] test]
catch {file delete -force $d}
file mkdir $d/d

close [open $d/f w]
close [open $d/d/f2 w]

exec ln -s f2 $d/d/l2
exec ln -s ../f $d/d/l

puts [vfs::filesystem fullynormalize $d/f]
puts [vfs::filesystem fullynormalize $d/d/l]
puts [vfs::filesystem fullynormalize $d/d/l2]
User Comments:
zoro2 added on 2012-10-17 18:50:04:
I have updated the script to show that the issue is with [file normalize] itself:

set d [file join [file dirname [info script]] test]
catch {file delete -force $d}
file mkdir $d/d

close [open $d/f w]
close [open $d/d/f2 w]

exec ln -s f2 $d/d/l2
exec ln -s ../f $d/d/l

puts [vfs::filesystem fullynormalize $d/f]
puts [file normalize $d/f]

puts ""
puts [vfs::filesystem fullynormalize $d/d/l]
# the first one returns test/d/f; second reports test/f
puts [file normalize $d/d/l/../../f]
puts [file normalize $d/d/l2/../../f]

puts ""
puts [vfs::filesystem fullynormalize $d/d/l2]
# the first one returns test/f2; second reports test/d/f2
puts [file normalize $d/d/l/../f2]
puts [file normalize $d/d/l2/../f2]

serhiy.storchaka added on 2026-10-19 18:44:30:

Still present in 8.6, 9.0 and 9.1: when ".." follows a link, the link target is used literally, so ".." or "." in the target, a trailing "/" or a chain of links give a wrong result (d/l/.. with l -> ../x gives d/..).

Proposed fix in branch normalize-dotdot-after-link, together with [3570244fff], [3183016fff] and [3099612fff]: on Unix the link target is normalized and further links are followed before backing up, so the results agree with realpath(). Tests filesystem-1.55 to 1.58. The last component of a path is still not resolved, as documented.