Artifacts Associated With Ticket 7eb6b3a53f963364
Ticket change [29a3301caa] (rid 254118) by anonymous on 2026-05-29 07:48:54:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- comment initialized to:
Glob on windows unc path sometimes works incorrectly: % llength [glob //?/C:/WINDOWS/*] 112 % llength [glob {\\?\C:\WINDOWS\*}] no files matched glob pattern "\\?\C:\WINDOWS\*" % llength [glob "\\\\?\\C:\\WINDOWS\\*"] no files matched glob pattern "\\?\C:\WINDOWS\*" With additional slash: % llength [glob {\\?\C:\WINDOWS\\*}] 112 % llength [glob "\\\\?\\C:\\WINDOWS\\\\*"] 112 (latest tcl 9.1 from repo on windows 10) This behavior seems inconsistent. - foundin initialized to: "8.4-9.1"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "36. Pathname Management"
- title initialized to: "glob on UNC path requires additional slash"
- type initialized to: "Bug"
Ticket change [3a9afccfa0] (rid 254121) by oehhar on 2026-05-29 08:43:22:
- icomment:
Bug confirmed. Great catch! Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [fdbf6ce568] (rid 254122) by apnadkarni on 2026-05-29 11:54:36:
- icomment:
That is not a UNC path. As far as I can see, UNC paths work correctly. ``` % llength [glob //IO/src/*] 124 % llength [glob {\\IO\src\*}] 124 % llength [glob "\\\\IO\\src\\*"] 124 ``` The `\\?\` notation follows different syntax rules and semantics. For example, `C:\foo\..\bar` and `\\?\C:\foo\..\bar` are *different* paths as are `C:\foo/bar` and `\\?\C:\foo/bar`, or `C:\foo\bar.` and `\\?\C:\foo\bar.` Tcl does not really support the `\\?\` syntax. There are some hacks (sorry, but they really are hacks) within Tcl that attempt to deal with this in piecemeal fashion. They lead you to believe that syntax is supported but it isn't. Moreover, in my opinion this is actually not fixable because not even all Win32 API's that Tcl uses understand the syntax. See [bc7925fc50](https://core.tcl-lang.org/tcl/tktview/bc7925fc50) for other cases. - login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [4b595d9b0d] (rid 254123) by anonymous on 2026-05-29 12:26:41:
- icomment:
Same behaviour on network path: % llength [glob {\\srv\share\tmp\\*}] 132 % llength [glob {\\srv\share\tmp\*}] no files matched glob pattern "\\srv\share\tmp\*" I'm using native windows shares from windows domain - login: "anonymous"
- mimetype: "text/plain"
- icomment:
Ticket change [d1c86832b4] (rid 254124) by anonymous on 2026-05-29 12:34:11:
- icomment:
Hmm, works great in the top directory % llength [glob {\\srv\share\\*}] 31 % llength [glob {\\srv\share\*}] 31 - login: "anonymous"
- mimetype: "text/plain"
- icomment:
Ticket change [0a3291c44f] (rid 254125) by apnadkarni on 2026-05-29 13:12:28:
- icomment:
Indubitably a bug then :-) Also present in 8.6
- login: "apnadkarni"
- mimetype: "text/plain"
- severity changed to: "Important"
- icomment:
Ticket change [800650d7b7] (rid 254139) by apnadkarni on 2026-05-31 04:40:03:
- icomment:
Reversing myself yet again, I think works as designed, confusing as it might be. When globbing a component like `Windows\*`, the glob syntax will treat `\` as escaping the following character, the `*`. So it is looking actually looking for the string `Windows*` (i.e. `*` is a literal character in the pattern, not a wildcard) which fails. The additional `\` is needed to escape the `\`. The confusing part is why the `\` in the UNC leading part does not need to be doubled. Tcl parses the path into a filesystem component and a pattern. The driver for the owning filesystem is then passed the pattern. The filesystem component itself is **not** treated as a pattern. In the following: ``` glob {\\io\src\tcl-cffi\*} ``` The file system component is parsed as `\\io\src\`. The pattern is `tcl-cffi\*`. The asterisk then treated not as a wildcard but an escaped literal character and no file names are returned. The reason top level wildcards as in `\\io\src\*` work is that again the file system component is `\\io\src\` and the pattern is simply `*` (unescaped). The same issue arises with simple drive paths as well, only even more confusing :-) because of the potential for drive-relative paths. The path `C:/*` is treated as file system `C:/` and pattern `*`. Is the path `C:\*` to be treated likewise or as a volume relative path with file system `C:` and an escaped `\*` literal asterisk? It appears the latter option is chosen so `glob {C:\*}` will return no files. I'm not sure there is a satisfactory solution to all this due to the inherent ambiguities. All I can suggest is to use Tcl canonical (forward slash) patterns as far as possible. Above analysis is not authoritative :-) so leaving ticket open. - login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [4fdeb7f7c1] (rid 254144) by oehhar on 2026-05-31 16:18:59:
- icomment:
At least this is reasonable, thanks Ashok for looking into this. Perhaps we can add something to the documentation: Native Windows path ({C:\test}) may only be used for the -directory and -path options. The glob pattern argument should use the forward slash as separator for unique results. Background is the ambiguity of the backslash character, which may escape a glob character ("\*" to specify a literal "*" character). So, for "glob {C:\test\*}", it is not clear, if the last backslash is a path separator or an escaped glob character. Take care, Harald - login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment: