fix: treat bare parentheses as literals (Fixes #171) - #212
Closed
dyk1454683243-sudo wants to merge 2 commits into
Closed
dyk1454683243-sudo wants to merge 2 commits into
dyk1454683243-sudo wants to merge 2 commits into
Conversation
Unprefixed `(...)` wraps were compiled as capture groups, so `/foo/(a)` matched `/foo/a` even with `noextglob: true`. Bash treats bare `(` / `)` as literals; only extglobs (`?(`, `*(`, `+(`, `@(`, `!(`) and regex extensions (`(?:`, lookarounds) or groups whose body needs grouping (`|`, wildcards, slashes) stay special. Fixes micromatch#171 Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Keep grouping for extglobs, regex extensions, quantified groups, and paren bodies that contain `|`, wildcards, slashes, or escapes. Update assertions that treated a plain `(literal)` wrap as a no-op capture group so the suite stays green with the micromatch#171 fix. Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Author
|
Withdrawing this PR while I clean up a high-volume open-PR backlog. Sorry for the noise — happy to come back later with a focused change if useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #171
Problem
Unprefixed parentheses in a glob were compiled as regex capture groups, so a pattern like
/foo/(a)matched/foo/a. That happens with or withoutnoextglob: true, becausenoextglobonly disables extglob prefixes (?(,*(,+(,@(,!() and does not change how a bare(is compiled.Bash treats bare
(/)as literals. Expected match isfalse:Fix
In the parse/compile path, compile bare
(and)as literal characters unless they form a real grouping construct:?(,*(,+(,@(,!((?:, lookarounds|, wildcards, slashes, escapes)(a)*and(a)+Inert wraps such as
(a)stay literal, so/foo/(a)matches/foo/(a)and not/foo/a. Existing extglob behavior is unchanged.Tests
noextglob), plus checks that real extglobs still match(literal)wrap as a no-op capture group were updated to the bash-compatible resultnpx mocha --reporter spec: 1999 passingnpx eslinton the touched files: clean