Skip to content

grep's glob filter is ignored for a named file (while the summary says it ran), and the pattern its description advertises selects nothing #2063

Description

@how2how2how2-arch

Measured 2026-10-10 (cyc20261010-220909) on master 2673769b, in this checkout.

grep's glob parameter answers two different questions under one name: it filters the
directory branch, and it is ignored by the file branch while the summary still says it
was applied — and the pattern its own description advertises selects nothing at all.

1. A named file is not filtered, and the reading says it was

$ # emrg/tools/read_tool.py holds one "def definition"
$ grep pattern="def definition" path=emrg/tools/read_tool.py                     
Found 1 matches ... (searched 1 files)
$ grep pattern="def definition" path=emrg/tools/read_tool.py glob="*.py"          
Found 1 matches ... (searched 1 files)
$ grep pattern="def definition" path=emrg/tools/read_tool.py glob="*.nomatch"     
Found 1 matches ... (searched 1 files)          <- identical to no filter at all

*.nomatch matches nothing in any tree, so the third call is a search of a file the
caller's own filter excludes. When the file happens to hold no match, the same call reads:

No matches for 'def main' in .../read_tool.py (searched 1 files) matching '*.nomatch'

matching '*.nomatch' is a claim about a filter that never ran. The description says
"Only search files matching this glob pattern", and the code (master):

if root.is_file():
    files = [root]                    # `file_glob` is not consulted
else:
    files = self._collect_files(root, file_glob)

The directory branch applies it, so the same parameter means two things depending on
whether path names a file.

2. The pattern the description advertises selects nothing

The glob parameter's description lists its examples as
Examples: '*.py', '*.{py,rs}', 'src/**/*.ts'. — and the walk is Path.rglob, whose
pattern language has no brace expansion. *.{py,rs} is not two patterns; it is one
literal string that matches no file whose name contains a brace. Over emrg/tools/:

glob='*.py'       ->  Found 9 matches for 'def definition' ... (searched 15 files)
glob='*.{py,rs}'  ->  No matches for 'def definition' ... (searched 0 files)

No matches is the sentence a real absence produces, so a model that follows the
description's own example is told "this pattern does not occur in the tree" about a
question the tool never asked. Nothing in the repo passes a brace pattern — the
description is its only user.

The same holds for glob's sibling: glob pattern='**/*.{py,md}' answers
No files matched pattern '**/*.{py,md}' on a tree that plainly holds both kinds of file.

Acceptance

  • the glob filter is applied to a named file too (the same predicate the directory
    branch uses), so glob means one thing;
  • a search that names one file and is excluded by the filter says which of the two
    readings it is (searched 0 files plus the reason), rather than printing a filter it
    did not apply;
  • a brace pattern is refused with the reason by both grep and glob — never
    searched to an empty answer that reads like a true one — through one shared rule;
  • the description's examples are true: a test reads the advertised list out of the schema
    and runs each one against a tree holding the file it names, so an unreadable form cannot
    re-enter it.

Activity

  1. how2how2how2-arch commented on Oct 10, 2026

    @how2how2how2-arch
    CollaboratorAuthor

    Handled by #2064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions