From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29085 invoked by alias); 14 Jul 2013 16:50:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17871 Received: (qmail 3198 invoked from network); 14 Jul 2013 16:49:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at m.gmane.org designates 80.91.229.3 as permitted sender) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Thorsten Kampe Subject: Re: How to iterate over an array of associative arrays Date: Sun, 14 Jul 2013 18:49:27 +0200 Message-ID: References: <20130714161437.GA25112@mugenguild.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-62-143-201-36.unitymediagroup.de User-Agent: MicroPlanet-Gravity/3.0.4 * Valodim Skywalker (Sun, 14 Jul 2013 18:14:37 +0200) > > I couldn't get that to work, either. The associative part seems to be > lost after (P) indirection, since elements can be addressed numerically. > > Anyways, here's an alternative suggestion: > > typeset -A a1 a2; > arr=( a2 a1 ); a1=(key val1); a2=(key val2); > for i in $arr; echo ${(e):-\$$i\[key]} > > This uses (e), so beware of security implications. ...works. What for christ's sake does it do? (Of course, I could try to figure it out on my own, but that might take a few days...) Thorsten