Skip to content

Fix glob matching a hidden name with a wildcard after a leading star - #253

Merged
facelessuser merged 1 commit into
facelessuser:mainfrom
spicysharkco:fix/star-hidden-dot
Oct 25, 2026
Merged

facelessuser merged 1 commit into
facelessuser:mainfrom
spicysharkco:fix/star-hidden-dot

Conversation

@spicysharkco

Copy link
Copy Markdown
Contributor

In a directory with .env, prod.env, and prod_env, glob.glob('*[._]env', root_dir=d) returns all three, but names starting with dot are not matched "unless matched with a literal dot". ?a, fnmatch, and Bash 5.3 already refuse the dot.

A leading * may match nothing, leaving ? or [...] after it unguarded. _restrict_sequence already guards this after an extended group; it now does the same after a star or a top-level !(...). *.a still matches .a.

Three new rows fail before the fix; a DOTGLOB row passes both ways.

A `?` or bracket expression right after a leading `*` could match the
leading dot of a name, such as `*?a` matching `.a`. Add the leading-dot
guard that wildcards after an extended group already use.
@gir-bot gir-bot added S: needs-review Needs to be reviewed and/or approved. C: docs Related to documentation. C: glob Glob library. C: pattern-parser Related to pattern parsing. C: source Related to source code. C: tests Related to testing. labels Oct 25, 2026
@facelessuser

Copy link
Copy Markdown
Owner

@gir-bot lgtm

@gir-bot gir-bot added S: approved The pull request is ready to be merged. and removed S: needs-review Needs to be reviewed and/or approved. labels Oct 25, 2026
@facelessuser
facelessuser merged commit 38cc8a5 into facelessuser:main Oct 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: docs Related to documentation. C: glob Glob library. C: pattern-parser Related to pattern parsing. C: source Related to source code. C: tests Related to testing. S: approved The pull request is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants