Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-09-18
16:27 • Closed ticket [bca391ab51]: cd and file normalize inconsistency with volume-rela... artifact: c75e86aa11 user: sebres
16:26
ultimatelly closes [bca391ab51cd48e7]: fixed regression introduced in [38f0ce657c] (don't use 2nd dr... check-in: 56afc6b1bc user: sebres tags: trunk, main
16:10 • Open ticket [bca391ab51]: cd and file normalize inconsistency with volume-relati... artifact: 0b4cbf5d5c user: sebres
2026-03-25
06:19 • Closed ticket [bca391ab51]. artifact: 085845f69e user: apnadkarni
06:14
Fix [bca391ab51]. Track current directory for each drive on Windows check-in: 38f0ce657c user: apnadkarni tags: trunk, main
2026-03-20
16:53 • Ticket [bca391ab51] cd and file normalize inconsistency with volume-relative pat... artifact: 5e1d1e223a user: apnadkarni
16:49 • Ticket [bca391ab51]: 3 changes artifact: e6249cc0db user: apnadkarni
2026-03-19
12:06
Bug [bca391ab51] - normalization of volume-relative files - WIP. check-in: b71c3b2471 user: apnadkarni tags: bug-b71c3b2471
2026-03-18
16:18 • New ticket [bca391ab51] cd and file normalize inconsistency with volume-relative... artifact: 11abf667c9 user: apnadkarni

cd and file normalize inconsistency with volume-relative paths on Windows

Closed / Fixedbca391ab51cd48e76b67b6e23e505f14f07dc4dfCreated 259 days agoUpdated 75 days ago
Descriptionmarkdown2026-03-18 16:18:58

The following shows inconsistencies in behaviour in the use of volume-relative paths. At the DOS command level, current directory for drives C: and D: are tcl and src respectively.

c:\Tcl>d:

D:\src>tclsh
% cd d:
% pwd
D:/src
% cd c:
% pwd
C:/

Along similar lines,

D:\src>tclsh
% file normalize d:
D:/src
% file normalize c:
C:/

does not seem consistent given that the current directory on C: at the OS level was not root.

I think volume relative paths should be resolved relative to the current directory on that volume as seen at the process / OS level.

Referenced by2
apnadkarnimarkdown2026-03-20 16:49:10

A more obvious inconsistency with Windows user expectations:

Command shell:

D:\src>pwd
D:\src
D:\src>cd C:
C:\
D:\src>cd d:
D:\src
D:\src>pwd
D:\src

vs Tcl:

D:\src>tclsh
% pwd
D:/src
% cd c:
% cd d:
% pwd
D:/
apnadkarnimarkdown2026-03-20 16:53:24

Proposed solution in bug-b71c3b2471. This tracks current directory per drive via env variables as in CMD.EXE so exec's will also inherit the mappings.

An alternative would be to always treat X: as X:/ (the root dir). This would also be consistent (and of course trivial to implement) but would not reflect user expectations that are based on the Windows command line.

apnadkarniplain2026-03-25 06:19:27
Fixed in [38f0ce657c] as no objections raised on core. Not backported to 9.0 as I don't think such a change should go into a patch release.
sebreswiki2026-09-18 16:10:58

I don't think the fix is fully correct, or rather doesn't introduce an error in case if current directory (where test-suite started) not in the first drive. Still worse it would be if current directory is neither in first nor in second drive.
Moreover it seems to overwrite path unconditionally (in line 339), what causes the set path in else case doesn't matter at all.

But even without that overwrite this test will fail if current directory is T:/Temp (like my TEMP folder on RAM drive T:), so the comparison [file norm $path] with [file join $dir foo] happens on "D:/foo" (normalized "D:foo") and "T:/Temp/foo" (what obviously never equal).

sebreswiki2026-09-18 16:27:31

Fixed in [56afc6b1bcc19c16] now.

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