help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: linuxtechguy@gmail.com
Cc: zsh <zsh-users@zsh.org>
Subject: Re: glob inside nested parameter expansion returns glob string
Date: Thu, 21 Apr 2022 12:15:31 -0700	[thread overview]
Message-ID: <CAH+w=7Yvrhv5tdPykG8RCcO1joXETP-cOO+mRaGLe6gNijdZSQ@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3SMjNwRc9zkL+=-F0zPgpzMks1EFBUwHDkUL5AsP_4GqQ@mail.gmail.com>

On Thu, Apr 21, 2022 at 11:51 AM Mikael Magnusson <mikachu@gmail.com> wrote:
> On 4/21/22, Jim <linux.tech.guy@gmail.com> 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) )

  reply	other threads:[~2022-04-21 19:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 17:24 Jim
2022-04-21 18:51 ` Mikael Magnusson
2022-04-21 19:15   ` Bart Schaefer [this message]
2022-04-21 20:37     ` Jim
2022-04-21 21:00       ` Jim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Yvrhv5tdPykG8RCcO1joXETP-cOO+mRaGLe6gNijdZSQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=linuxtechguy@gmail.com \
    --cc=zsh-users@zsh.org \
    --subject='Re: glob inside nested parameter expansion returns glob string' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).