Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: glob inside nested parameter expansion returns glob string



Sorry, thought I had extendedglob set, works fine.

On Thu, Apr 21, 2022 at 3:37 PM Jim <linux.tech.guy@xxxxxxxxx> wrote:
Thanks everyone for the responses.

On Thu, Apr 21, 2022 at 2:15 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
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)*})
 
Came fairly close on this one while trying different ways.  Didn't use a print
command. :-(

However, with extendedglob this specific example can be done entirely
with globbing:

A=( .z*~*(comp|hist)*(.N) )

Is there a typo or something missing here? This didn't find any files when I
cut and pasted it in a shell.

ZSH_VERSION  5.8
ZSH_PATCHLEVEL  debian/5.8-6+deb11u1
 
Again, thanks,

Jim Murphy


Messages sorted by: Reverse Date, Date, Thread, Author