Overview
| Artifact ID: | 30f75b7c0618278e58b5efa91ce51e5a3fd761f2114aba596298f1fbfa5c9028 |
|---|---|
| Ticket: | b0682c3c2497e8f27f18e91686031dda055ed19c
glob error |
| User & Date: | apnadkarni on 2026-03-18 16:04:36 |
Changes
- comment changed to:
I have the following strange behaviour under Windows 10 with tcl_patchLevel=9.0.0 (and tcl_patchLevel=9.0.1 from BAWT) (bin) 1 % set tcl_patchLevel 9.0.0 (bin) 2 % glob Z:/Basistests/200* Z:/Basistests/2000_00_00 {Z:/Basistests/2000_00_00 - Test} (bin) 3 % glob -types d Z:/Basistests/200* Z:/Basistests/2000_00_00 {Z:/Basistests/2000_00_00 - Test} (bin) 4 % glob -types d -directory Z:/Basistests -tails Z:/Basistests 200* Z:Basistests 2000_00_00 {2000_00_00 - Test} (bin) 5 % glob -types d -directory Z:/Basistests -tails Z:/Basistests Z:/Basistests/200* couldn't read directory "Z:/Basistests/Z:Basistests/200*": not a directory Under tcl8 I got: (ABS) 1 % glob -types d -directory Z:/Basistests -tails Z:/Basistests 200* 2000_00_00 {2000_00_00 - Test} (ABS) 2 % glob -types d -directory Z:/Basistests -tails Z:/Basistests Z:/Basistests/200* no files matched glob patterns "Z:/Basistests Z:/Basistests/200*" The additional string "Z:Basistests" on comcd mand 4 is wrong. Even more perplexing is the following (under Tcl/Tk 9.0.0): (ABS) 1 % glob -types d -directory Z:/Basistests -tails Z:/Basistests 200* Z:Basistests 2000_00_00 {2000_00_00 - Test} (ABS) 2 % cd Z:Basistests (Basistests) 3 % pwd Z:/Basistests (Basistests) 4 % cd C: () 5 % cd Z:Basistests (Basistests) 6 % cd 2000_00_00 (2000_00_00) 7 % cd Z:Basistests couldn't change working directory to "Z:Basistests": no such file or directory (2000_00_00) 8 % - icomment:
Potential fix in the [bug-b0682c3c24](https://core.tcl-lang.org/tcl/timeline?r=bug-b0682c3c24) branch. But see below. ``` % glob d:/Basistests/200* d:/Basistests/2000_00_00 {d:/Basistests/2000_00_00 - Test} % glob -types d d:/Basistests/200* d:/Basistests/2000_00_00 {d:/Basistests/2000_00_00 - Test} % glob -types d -directory d:/Basistests -tails d:/Basistests 200* 2000_00_00 {2000_00_00 - Test} % glob -types d -directory d:/Basistests -tails d:/Basistests d:/Basistests/200* % ``` which seems reasonable to me. The cd issues in the original ticket I didn't quite understand as it seems to be it depends on what the "current directory" on the other drive happened to be. In the existing implementation, glob correctly parses the `-directory` and pattern into components `d:/basictests`, `d:` and `basictests`. However when checking for existence, the implementation invokes `Tcl_FSTranslatePath` which reparses the path by calling `TclJoinPath` which behaves as the script level `join` command which discards any components prior to anything an absolute or volume-relative component. In this case `d:` is the volume relative component so the existence check is made against "d:Basictests". The result will then depend on whether the "current directory" on drive D: is the root or not. As a fix, it seems to me that `Tcl_FSGetTranslatedPath` is broken in this behaviour. Not only is this "join-like" behaviour mentioned anywhere in the documentation, I also think it does not make semantic sense. The function is supposed to translate a single path and should not be discarding any components. In particular on Unix, it already behaves this way by not treating a leading `/` in a pattern as an absolute path. ``` % glob -directory /tmp /foo /tmp/foo ``` I therefore consider this as a bug fix and not a change to defined or expected `Tcl_FSGetTranslatedPath` behavior (which would require a TIP). Opinions? - login: "apnadkarni"
- mimetype: "text/x-markdown"