Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: nested parameter expansion
- X-seq: zsh-users 26083
- From: "jdh" <dhenman@xxxxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Re: nested parameter expansion
- Date: Thu, 24 Sep 2020 10:07:26 -0700
- Archived-at: <https://zsh.org/users/26083>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-09/20200924100726.5496%40binki>
- Authentication-results: zsh.org;	iprev=pass (mail-pf1-f176.google.com) smtp.remote-ip=209.85.210.176;	dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256;	dmarc=pass header.from=gmail.com;	arc=none
- Cc: 
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=to:cc:subject:in-reply-to:references:date:from:message-id;        bh=eY+X8fsWuZ7LLgqnUPPly48EFsSSzp8FoLBLr4T06vM=;        b=a3B2XBdZAbY/gxmCBcM4v8H5Q+m2tLa6TUbZquFfO2UQVCPJAddPZXRLv7Xxd5ln6g         PxNiC6leD34veQx6h7JUE0RKEdwq/OW5Wn4eAkaBUcDgDK6zWY0PTt/j18d4zq5OlfH/         PewacdUfP095z9ROE2Z1xB5ZgWUswrMfAXyHmMJIUpR6VdqyB+mAAbgU25/UQ8+YRlNC         I8oJjsXUaHZlsBYSnr3rSzoTNJq45arGnF8w5O5jOrcQ+ezNK6RHMuha32mObRoP5NXa         8RcemUSwWoOci3VZgL63tvocyaGfm+3q1vUOJmlPsj1kqxFhEnMcgso6e2jRJ8pSXH2k         roEg==
- In-reply-to: Your message of Thu, 24 Sep 2020 09:15:25 +0100 (BST)	<1356305032.19895.1600935325161@mail2.virginmedia.com>
- 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>         <1356305032.19895.1600935325161@mail2.virginmedia.com>
- Sender: zsh-users-request@xxxxxxx
Thanks for the information Roman & Peter.
Much appreciated.
---------
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> 
> > 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