Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: nested parameter expansion
- X-seq: zsh-users 26080
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: nested parameter expansion
- Date: Thu, 24 Sep 2020 09:15:25 +0100 (BST)
- Archived-at: <https://zsh.org/users/26080>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-09/1356305032.19895.1600935325161%40mail2.virginmedia.com>
- Authentication-results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1600935325; bh=8RnBpAYeBbEMKX882SuTB3Q3kuRgw+edqTI3EVbfBZc=; h=Date:From:To:In-Reply-To:References:Subject; b=g5oNO9Afmd7B91RffwR9mYUiKaUdSVylzWCyg0FliNYFoLcab3ghl+W2cPf52Ge0+ F693b3VTFnpTz6bH4zMUfVEU3D5RZ0TJR9NESscrkQywTvomgrfRWH/XbMVe2GA5PW A0yMtIqHDtfOF7+QWr25B6paKyzbdH4j7jK9QmTKVovxjtxEWsvQXXhCVb6Q8wltLK KhH3phhZZgzOgIvC3f83RFHyzif6eFCcfWaOJ1d4CzNeCL4nRJaKwIYHhW5i4mn4o1 WNHaHfoeLQmK2AvTcWEdqA8YCKR2BmuyNJvIVyQMjPrAtjrY8XG3WJXJNeRcUBiCqa lgd8PteS4b3Cg==
- Importance: Medium
- In-reply-to: <20200924010311.7083@binki>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-users>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-users.zsh.org>
- List-owner: <mailto:zsh-users-request@zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-users>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-users>
- References: <20200924010311.7083@binki>
- Sender: zsh-users-request@xxxxxxx
> On 24 September 2020 at 09:03 jdh <dhenman@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author