#1275 Glob doesn't deal properly with * and [

obsolete: 8.4a1

OriginalBugID: 6101 Bug
Version: 8.4a1
SubmitDate: '2000-08-09'
LastModified: '2000-09-05'
Severity: LOW
Status: Assigned
Submitter: techsupp
ChangedBy: hobbs
OS: Windows NT
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'

Michal Prussak

Not really a big deal, but I thouht you should know.

Create files with names "*" and "[" (OK, * is perhaps bad, because NT applications can't access a file
with a * in the name anyway)

% glob {\*}
<gives listing of root directory>
% glob {\[}
no files matched glob pattern "\["

Files * and [ have not been matched

Files * and [ should have been matched, just like on Unix:

% glob {\[}
% glob {\*}

Verified this on 8.3.2 for Windows.
-- 09/05/2000 hobbs


  • Donal K. Fellows

    • labels: 104242 --> 104681
  • Donal K. Fellows

    Probably a fault in the Windows implementation of TclpMatchFilesTypes()

  • Donal K. Fellows

    • labels: 104681 --> 36. Pathname Management
  • Andreas Kupries

    Andreas Kupries - 2001-08-23
    • assigned_to: nobody --> vincentdarley
  • Vince Darley

    Vince Darley - 2001-08-24
    • assigned_to: vincentdarley --> hobbs
  • Vince Darley

    Vince Darley - 2001-08-24

    Logged In: YES

    This is, I believe, nothing to do with
    TclpMatchFilesTypes. Since we are matching a literal
    string here, 'glob' falls through to the end of TclDoGlob
    which simply checks for existence of the file, using
    Tcl_FSAccess (or since the patch was checked in yesterday)
    Tcl_FSLStat. However, looking at the implementation of
    stat on WinTcl, I see this:

    * Eliminate file names containing wildcard characters,
    or subsequent
    * call to FindFirstFile() will expand them, matching
    some other file.

    transPtr = Tcl_FSGetTranslatedPath(NULL, pathPtr);
    if (transPtr == NULL || (strpbrk(Tcl_GetString
    (transPtr), "?*") != NULL)) {
    return -1;

    i.e. we purposefully disallow ourselves from statting any
    file with '*' or '?' in the name. Since this bug is
    reported against older versions of Tcl, it seems as
    if 'access' has the same limitation (although it doesn't
    seem to be explicitly coded in Tcl's core). I assume this
    is therefore a limitation of the Win32 api's we use, and
    therefore cannot be fixed (at least without changing those

    I'm therefore assigning this to Jeff, since he seems to
    know something about the 'real Win32' stuff (and I don't)

  • Nobody/Anonymous

    Logged In: NO

    Note: this is related to the 'speed up stat 100x on
    Windows' patch # 403001, in that if we apply a version of
    that patch, then we no longer need to eliminate file names
    contain wildcards, and this bug will go away.

  • Vince Darley

    Vince Darley - 2001-09-20

    Logged In: YES

    I don't know how to create a file called '*' on Win2000
    (using Tcl or not) so I can't test the first part of the
    bug, but I can make '[' work with the patch attached. This
    is basically the 'patch to speedup stat 100x' (although the
    speed up seems smaller). It seems to pass all tests on
    Win2000, but should be tested on Win9x to make sure I've
    got the 'A' as well as 'W' APIs correct.

  • Vince Darley

    Vince Darley - 2001-09-20

    unified diff in 'win' directory, with win eols

  • Vince Darley

    Vince Darley - 2001-10-29
    • assigned_to: hobbs --> vincentdarley
    • status: open --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks