Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dd5ea837041b9f435cf27b6c71c00a8f72b72b8831c5fc519d8f60773444c5d2
Ticket: a382a311e098c19ae3abe371602eb84d7a1e00e6
glob on case insentitive sytems not respecting character class case
User & Date: juliannoble2 on 2026-03-28 05:02:28
Changes

  1. comment changed to:
    related but I suspect different to https://core.tcl-lang.org/tcl/tktview/108904173c
    
    An example on windows c:/windows/system32 folder (which is one of the largest default directories on a windows system)
    
      %llength [glob {[a]*}]
      246
      %llength [glob {[A]*}]
      246
      %llength [glob {[aA]*}]
      246
    
    I have an alternative command fglob that I implemented using twapi that can produce correct results.
    
      %llength [fglob {[a]*}]
      118
      %llength [fglob {[A]*}]
      128
      %llength [fglob {[aA]*}]
      246
    
    I expect on a case-insensitve system that characters outside either character classes or braced-alternative globs should be case-insensitive, but character classes such as [a-z] [A-Z] should be respect the case of the file as stored on the system - which is clearly possible to do, and at least in the cases I tested - pretty performantly.
    
    As a side note - my wrapper is using tcl script and twapi but no other c code - and is understandably slower on many simple queries such as *, it can outperform the builtin glob on some of the more complex glob queries.
      
      %time {glob {[a]*}}
      9444 microseconds per iteration
    
      %time {fglob {[aA]*}}
      3164 microseconds per iteration
      %time {fglob {[a]*}}
      1820 microseconds per iteration
    
    This suggests that there may be justification for re-examining the mechanisms being used here - although I don't claim to know all the tradeoffs that could be required to preferably optimise for simple cases.
    
    I would expect my tcl/twapi alternative to be slower in all cases.
    
    The difference is large enough that I don't think it's related to any side issues such as option parsing or checking for vfs etc (which I also do anyway)
    My fglob also handles braced expressions (even nested) and generates fairly complex regexps to post-process the result from necessarily broader queries that the underlying windows system accepts (only * and ? globs).
    
    Whilst I haven't set up tests to verify my fglob supports all possible valid globs (e.g processing escaped glob characters in all levels of nesting) the time difference is still a bit suspicious to me, and the simple cases above should be faster regardless of glob expression processing or post-retrieval filtering which I wouldn't expect to dominate.
    
    My time tests are on a modern fast nvme ssd - so I can't suggest that my glob vs fglob timings above are indicative for spinning rust systems, although testing on a mapped network drive from a share on a remote system the fglob version was still significantly faster than glob for those basic character-class queries.
    
  2. login: "juliannoble2"
  3. mimetype: "text/plain"