Glob patterns w/ **; zero or more?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I noticed that, in a repo with a single `main.c` file, `git ls-files
'./**/main.c'` (note the surrounding quotes, to avoid shell globbing)
returns no result even though `git ls-files main.c` does. It however
can find any `main.c` file located in a subdirectory, suggesting `**`
is interpreted as "one or more" rather than "zero or more". Can you
confirm it'd be a bug? I checked in both 2.38 and 2.40.

For reference, the documentation is explicit that `**` is "zero or
more", not "one or more", and it matches the behaviour from other glob
implementations (emphasis mine):

> A slash followed by two consecutive asterisks then a slash matches ***zero or
> more directories***. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

Also quoting the bash documentation for reference:

> globstar
> If set, the pattern ‘**’ used in a filename expansion context will match all files
> and zero or more directories and subdirectories. If the pattern is followed by
> a ‘/’, only directories and subdirectories match.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux