From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: nested parameter expansion
Date: Thu, 24 Sep 2020 09:15:25 +0100 (BST) [thread overview]
Message-ID: <1356305032.19895.1600935325161@mail2.virginmedia.com> (raw)
In-Reply-To: <20200924010311.7083@binki>
> On 24 September 2020 at 09:03 jdh <dhenman@gmail.com> wrote:
> I can't get, what should be simple nested parameter to work.
> I think that $ndx needs to be expanded before the letter P before it 1st.
>
> Simple example:
>
> ndx=1
> P1_ARRAY=("1" "2" "3")
>
> print ${P${ndx}_ARRAY}
> #results in: "zsh bad substitution
I don't think there's a simple way to do it without an extra intermediate
variable:
var="P${ndx}_ARRAY"
print ${(P)var}
You could add some eval trickery, but I suspect it's not worth making it any
more complicated.
pws
next prev parent reply other threads:[~2020-09-24 8:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 8:03 jdh
2020-09-24 8:15 ` Peter Stephenson [this message]
2020-09-24 8:29 ` Roman Perepelitsa
2020-09-24 17:07 ` jdh
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356305032.19895.1600935325161@mail2.virginmedia.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).