Re: A question about filename generate

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.user
Message-ID <CAHYJk3TYV=UnODAB7gd059wGX=0ebe9BqP0EGCbxxiq2HrdpDA@mail.gmail.com>
On Sun, Jul 27, 2025 at 7:26 AM safreya <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.