Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A question about filename generate
On Sun, Jul 27, 2025 at 7:26 AM safreya <safreya@xxxxxx> wrote:
>
> I'm confused about ** expansion.In the following example:
>
> safreya test % setopt extendedglob
> safreya test % print -l **/*~**/*.tex
> index.tex
>
> I notice that index.tex is printed. This means:
>
> 1. The first ** expansion include index.tex
> 2. The second ** expansion not
>
> Why?
in x~y, the x is a glob pattern, but y is a string pattern. **/ is
only special in globbing where it is a shorthand for (*/)#. In string
matching it simply means any string followed by any string followed by
a slash. Additionally, in a string pattern, the "any string" can
include a / which it cannot in globbing, meaning that even x~*.tex
will exclude foo/bar/baz/quux.tex for example if that was generated by
the glob pattern x, because the * will match foo/bar/baz/quux.
Note also that ** on its own is not special in either context, only **/ is.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author