Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: glob inside nested parameter expansion returns glob string
- X-seq: zsh-users 27686
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: linuxtechguy@xxxxxxxxx
- Cc: zsh <zsh-users@xxxxxxx>
- Subject: Re: glob inside nested parameter expansion returns glob string
- Date: Thu, 21 Apr 2022 12:15:31 -0700
- Archived-at: <https://zsh.org/users/27686>
- In-reply-to: <CAHYJk3SMjNwRc9zkL+=-F0zPgpzMks1EFBUwHDkUL5AsP_4GqQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CA+rB6G+ujzDmSpyO8PE2SDTc_5jQeEPoLQbO4pqZ+0qeBg_Knw@mail.gmail.com> <CAHYJk3SMjNwRc9zkL+=-F0zPgpzMks1EFBUwHDkUL5AsP_4GqQ@mail.gmail.com>
On Thu, Apr 21, 2022 at 11:51 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On 4/21/22, Jim <linux.tech.guy@xxxxxxxxx> wrote:
> >
> > % A=(${:-.z*(.N)})
> > % A=(${A:#*(comp|hist)*})
> >
> > Is there a way to nest the two?
>
> There is a certain order that parameter expansions and globs happen
> relative to eachother [...] In short, no(t as far as I know).
Correct, this can't be done as a nested expansion, except by invoking
a subshell to perform the globbing.
A=(${${(@f):-$(print -rl .z*(.N))}:#*(comp|hist)*})
However, with extendedglob this specific example can be done entirely
with globbing:
A=( .z*~*(comp|hist)*(.N) )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author