Skip to content

Mark glob patterns #13

Closed
Closed

Description

@jcubic

This is a limitation of the parser. It marks only {foo,bar} as brace expansion. But this is part of the glob patterns. It would be nice if all glob patterns were marked as globs. So it's easier to handle.

Right now I use regular expressions to check Word::text and for BraceExpansion I just return text because it's part of the glob expansion handled in a different place.

Activity

  1. webpro commented on Oct 8, 2026

    @webpro
    Member

    Bash itself does not treat braces as pattern syntax. Brace expansion is a separate, purely textual step that runs before globbing: *.{js,ts} becomes the two words *.js and *.ts, and only then is each matched against the filesystem. nullglob leaves {foo,bar} alone, and in a case pattern or [[ x == {foo,bar} ]] the braces are literal characters. JS glob libraries fold brace expansion into matching, which makes the two look like one feature, but the Literal plus BraceExpansion split is what bash does.

    Marking unquoted *, ? and [...] is a separate request, and a fair one. Extglob groups like @(a|b) are already ExtendedGlob parts, but plain glob characters are ordinary text: inside a structured word they sit in Literal parts, and a word like foo* has no parts at all because it never leaves the plain-word fast path. A glob part adds a check to that fast path for every word, so it needs measuring first.

    You can already narrow the regexes, though: quoted parts never glob, and text keeps the backslash that value drops, both on parts and on a word without parts.

    Would a part for unquoted *, ? and [...], like ShellCheck's T_Glob, cover your case, with your glob library still handling the braces?

  2. jcubic commented on Oct 8, 2026

    @jcubic
    Author

    If braces are a different thing, it's ok to make them separate. I think that I can handle both using same glob library.

  3. webpro commented on Oct 15, 2026

    @webpro
    Member

    This took a while as it's a breaking change, so it's coming in v6. Feel free to explore docs/MIGRATION-v5-to-v6.md and give main a shot if you're up for it. Also note that v6 introduces forEachChild which might be convenient for traversal.

  4. webpro commented on Oct 15, 2026

    @webpro
    Member

    Preview releases are available, e.g. npm i https://pkg.pr.new/unbash@db63c2b

  5. webpro commented on Oct 16, 2026

    @webpro
    Member

    🚀 This issue has been resolved in v6.0.0. See Release 6.0.0 for release notes.

  6. added a commit that references this issue on Oct 20, 2026
    3430d10
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions