Tcl Source Code

View Ticket
Login
Ticket UUID: bca391ab51cd48e76b67b6e23e505f14f07dc4d
Title: cd and file normalize inconsistency with volume-relative paths on Windows
Type: Bug Created on: 2026-03-18 16:18:58
Submitter: apnadkarni Assigned to: nobody
Subsystem: - New Builtin Commands Severity: Minor
Priority: 5 Medium Last modified: 2026-09-18 16:27:31
Status: Closed Closed by: sebres
Resolution: Fixed Closed on: 2026-09-18 16:27:31
Version: 9.0
Description:

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.

User Comments:
apnadkarni added on 2026-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:/

apnadkarni added on 2026-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.


apnadkarni added on 2026-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.

sebres added on 2026-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).


sebres added on 2026-09-18 16:27:31:

Fixed in [56afc6b1bcc19c16] now.