Tcl Source Code

View Ticket
Login
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

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.