Skip to content

pattern: wrong results for /**foo #1149

Closed

Description

@paulhammond

While working on #1147 I think I noticed that the regexp generated for /**foo is incorrect.

https://go.dev/play/p/XXoRQ4EdBwV is some go code that matches /**foo against a number of paths; as you can see all three match.

Here's a bash shell in a container testing the same three paths:

$ echo $BASH_VERSION
5.2.15(1)-release
$ touch /foo
$ mkdir -p /a/b/c
$ touch /a/b/cfoo
$ touch /a/b/c/foo
$ ls /**foo
/foo

Bash only matches /foo, the pattern package matches all three paths. Is this a bug or am I missing something?

Activity

  1. mvdan commented on Apr 8, 2025

    @mvdan
    Owner

    We aim to emulate Bash behavior as closely as possible within reason, so this is likely a bug. The recursive globbing logic is surprisingly difficult to get exactly right. Happy to review a patch, otherwise I'll look at this sometime this week.

  2. mvdan commented on Apr 13, 2025

    @mvdan
    Owner

    This should be fixed now. See the commit adding test cases; this wasn't a bug in the interp or expand packages. It was only a bug when using the pattern package directly.

  3. added a commit that references this issue on Apr 13, 2025
    8a36c1e
  4. paulhammond commented on Apr 14, 2025

    @paulhammond
    ContributorAuthor

    Thanks for working on this so quickly! This looks right to me...

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

      ⌂ 换网址