zsh-users
 help / color / mirror / code / Atom feed
* nested parameter expansion
@ 2020-09-24  8:03 jdh
  2020-09-24  8:15 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: jdh @ 2020-09-24  8:03 UTC (permalink / raw)
  To: zsh-users


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

    print ${~P${ndx}_ARRAY}
#results in: "zsh bad substitution

    print ${(P)P${ndx}_ARRAY}
#results in: "zsh bad substitution

I want to do a simple 'for' loop like this:

  for ndx in ("1" "2" "3")		# for multiple arrays not defined in this simple example.
      do
      for element in ${P${ndx}_ARRAY}
        do
	print "Process element."
	done
     done


Any assistance would be appreciated





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-24 17:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24  8:03 nested parameter expansion jdh
2020-09-24  8:15 ` Peter Stephenson
2020-09-24  8:29   ` Roman Perepelitsa
2020-09-24 17:07   ` jdh

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).