Overview
| Artifact ID: | 800650d7b7e952b44ba92d1cd009bb7c9eceed1e6aef6557d221906575f5e880 |
|---|---|
| Ticket: | 7eb6b3a53f963364c3c6f29d7622d70ddf8dd610
glob on UNC path requires additional slash |
| User & Date: | apnadkarni on 2026-05-31 04:40:03 |
Changes
- 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"