Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Expand each array element with ${(P)...}
- X-seq: zsh-users 29643
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Marlon Richert <marlon.richert@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Expand each array element with ${(P)...}
- Date: Tue, 6 Feb 2024 08:25:21 +0100
- Archived-at: <https://zsh.org/users/29643>
- In-reply-to: <CAHLkEDt7_JcL2gX7b+DFbmwt+FaR_TfQftronc_47rOC4=Nttg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAHLkEDt7_JcL2gX7b+DFbmwt+FaR_TfQftronc_47rOC4=Nttg@mail.gmail.com>
On Tue, Feb 6, 2024 at 7:51 AM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
>
> I have an array of variable names that I would like to expand to an
> array of these variables' values.
You could use this (requires extended_glob):
${names/(#m)*/${(P)MATCH}}
Or this, if you need to retain empty elements:
"${(@)names/(#m)*/${(P)MATCH}}"
I don't know if there is a better way.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author