Skip to content

Recursive globs fail too early on partial path match #14934

Closed

Description

@refi64

What version of Bun is running?

1.1.31+e448c4cc3

What platform is your computer?

Linux 6.11.0-400.asahi.fc40.aarch64+16k aarch64 unknown

What steps can reproduce the bug?

console.log(new Bun.Glob(`**/*abc*`).match(`a/abc`))
console.log(new Bun.Glob(`**/*abc*`).match(`z/abc`))

What is the expected behavior?

true
true

What do you see instead?

false
true

Additional information

I'm pretty sure this is because the glob code sees the a and tries the parse the full abc, then bails out early when that fails?

Activity

  1. refi64 commented on Nov 1, 2024

    @refi64
    ContributorAuthor

    In glob_ascii.zig, we have:

    bun/src/glob_ascii.zig

    Lines 401 to 403 in 6933208

    // If this is not a separator, lock in the previous globstar.
    if (cc != '/')
    state.globstar.path_index = 0;

    I...don't think this is correct? In a/abc, it "locks in" at the first a, which makes no sense. Does this maybe need to maintain a stack or similar?

  2. Jarred-Sumner commented on Nov 1, 2024

    @Jarred-Sumner
    Collaborator
  3. Jarred-Sumner commented on Nov 2, 2024

    @Jarred-Sumner
    Collaborator

    @dylan-conway spent some time investigating. This bug is present in both the Zig and Rust library our glob implementation was partially based on

  4. dylan-conway commented on Nov 2, 2024

    @dylan-conway
    Member

    Likely the same bug: devongovett/glob-match#9

  5. marked Glob works incorrect #16526 as a duplicate of this issue on Jan 20, 2025
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

    bugSomething isn't workingbun:globRelated to Bun.Globconfirmed bugWe can reproduce this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions