All of lore.kernel.org
 help / color / mirror / Atom feed
* Glob patterns w/ **; zero or more?
@ 2023-04-16 18:40 Maël Nison
  2023-04-16 19:04 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Maël Nison @ 2023-04-16 18:40 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-16 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16 18:40 Glob patterns w/ **; zero or more? Maël Nison
2023-04-16 19:04 ` Andreas Schwab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.