#3739 Unexpected [glob] result, when types list is empty

obsolete: 8.5.3
closed-fixed
9
2008-08-14
2007-07-09
No

Hi *,

consider the following examples:

* there is a plain file TAGS in the current directory:

% glob -- TAGS tags Tags
TAGS
% glob -types {} -- TAGS tags Tags
TAGS tags Tags

* there is _no_ file "urgent" in the current directory:

% glob -types {} -- U*
no files matched glob pattern "*U*"
% glob -types {} -- URGENT Urgent
URGENT Urgent

Seems an empty types list together with queries without patterns just returns the queries...

% set tcl_patchLevel
8.4.14

Operating systems: Linux, AIX, HP-UX and Solaris

kind regards
-- Matthias Kraft

Discussion

  • Matthias Kraft

    Matthias Kraft - 2007-07-09

    Logged In: YES
    user_id=330806
    Originator: YES

    the second example: the query was *U* of cause.

    Got one line too less with CnP and then typed the missing line :-/ ...

    kind regards
    -- Matthias Kraft

     
  • Donal K. Fellows

    • priority: 5 --> 8
     
  • Anonymous - 2007-12-14

    Logged In: YES
    user_id=585068
    Originator: NO

    Cool bug:
    % cd /
    % glob -types {} -- TMP tmp
    TMP tmp
    % file exists TMP
    0
    % glob -- TMP tmp
    tmp

    Here's a patch that fixes it:
    Index: tclFileName.c
    ===================================================================
    RCS file: /cvsroot/tcl/tcl/generic/tclFileName.c,v
    retrieving revision 1.86
    diff -u -r1.86 tclFileName.c
    --- tclFileName.c 13 Dec 2007 15:23:17 -0000 1.86
    +++ tclFileName.c 14 Dec 2007 21:46:51 -0000
    @@ -1412,6 +1412,11 @@
    */

    Tcl_ListObjLength(interp, typePtr, &length);
    +
    + if (length <= 0) {
    + goto skipTypes;
    + }
    +
    globTypes = (Tcl_GlobTypeData*)
    TclStackAlloc(interp,sizeof(Tcl_GlobTypeData));
    globTypes->type = 0;
    @@ -1529,6 +1534,7 @@
    }
    }

    +skipTypes:
    /*
    * Now we perform the actual glob below. This may involve joining together
    * the pattern arguments, dealing with particular file types etc. We use a

     
  • Matthias Kraft

    Matthias Kraft - 2008-07-01

    Logged In: YES
    user_id=330806
    Originator: YES

    This one still persists in 8.5.3 ... Maybe someone could fix it one way or another.

    Thanks
    -- Matthias Kraft

     
  • Matthias Kraft

    Matthias Kraft - 2008-07-01
    • assigned_to: vincentdarley --> dgp
    • milestone: 595232 --> obsolete: 8.5.3
     
  • Don Porter

    Don Porter - 2008-08-13
    • status: open --> closed-fixed
     
  • Don Porter

    Don Porter - 2008-08-13

    Logged In: YES
    user_id=80530
    Originator: NO

    fix committed to all active branches.

     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580
    Originator: NO

    the tests added for this bug depend on the filesystem being case sensitive, which is not the case everywhere, e.g. not with HFS+ on Mac OS X, it does not seem necessary to test for the fix in this way

    ==== fileName-20.1 Bug 1750300 FAILED
    ==== Contents of test case:

    llength [glob -nocomplain -directory $d -- TAGS tags Tags]

    ---- Result was:
    3
    ---- Result should have been (exact matching):
    1
    ==== fileName-20.1 FAILED

    ==== fileName-20.2 Bug 1750300 FAILED
    ==== Contents of test case:

    llength [glob -nocomplain -directory $d -types {} -- TAGS tags Tags]

    ---- Result was:
    3
    ---- Result should have been (exact matching):
    1
    ==== fileName-20.2 FAILED

     
  • Daniel A. Steffen

    • priority: 8 --> 9
    • status: closed-fixed --> open-fixed
     
  • Don Porter

    Don Porter - 2008-08-14

    Logged In: YES
    user_id=80530
    Originator: NO

    You're right; I simply copied the
    test cases out of the bug report
    being too lazy to invent my own.

    I'll get these tests fixed tomorrow.

     
  • Don Porter

    Don Porter - 2008-08-14
    • status: open-fixed --> closed-fixed
     
  • Don Porter

    Don Porter - 2008-08-14

    Logged In: YES
    user_id=80530
    Originator: NO

    more portable tests committed.