From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17575 invoked by alias); 27 Feb 2015 14:02:14 -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: 19930 Received: (qmail 22465 invoked from network); 27 Feb 2015 14:01:59 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dyne.org; s=mail; t=1425045717; bh=Xv03Kbaaf5KJ2V5jFiQFKe9YrXRJTsKzIlMic6vz/P0=; h=Date:From:To:Subject:References:In-Reply-To:From; b=PEkJj7SVSUqinulLWZQBmBt9ua7BAkPodH9321m+cLp0fsyVqqPyKcjBl0t0yXEhS n2WnLgP9IMZ8Szqzzm457YriRgwT4fdbnRb3wFlMgl6rUQP6zafcNFhp0Lz6mTjoAe PaKwkcoV7zXDKUurtLfs8ERMbaxW0RoPzGVNNa0Y= Date: Fri, 27 Feb 2015 15:02:11 +0100 From: Jaromil To: zsh-users@zsh.org Subject: Re: pointers and associative maps Message-ID: <20150227140211.GA18843@fork> References: <20150227120941.GA15885@fork> <20150227124641.GA17275@fork> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150227124641.GA17275@fork> Organization: Dyne.org Free Software Foundry X-GPG-Keyserver: pgp.mit.edu X-GPG-Id: 4ACB7D10 [expires: 2018-09-05] X-GPG-Fingerprint: 6113 D89C A825 C5CE DD02 C872 73B3 5DA5 4ACB 7D10 User-Agent: Jaro Mail third reply to myself, now I'm embarassed. however: > solved! using ${(Pv)${_map}[$c]} this solves it only for values in the associative map, not for keys. So my problem persists and I wonder if there are solutions to this: use a pointer to an associative map to get out keys from it. Here a small function to help reproduce the situation typeset -A mappa zkv-test() { mappa+=(key1 value1) mappa+=(key2 value2) mappa+=(key3 value3) _map=mappa _num="${(P)#_map}" for c in {1..$_num}; do print "$c/$_num: ${(Pk)${_map}[$c]} ${(Pv)${_map}[$c]}" done } once launched, it prints: 1/3: 1 value1 2/3: 2 value2 3/3: 3 value3 where I believe it should be: 1/3: key1 value1 2/3: key2 value2 3/3: key3 value3 puzzling enough, after running the function one can do: print ${${(Pk)_map}[$c]} from the interactive console, moving the (Pk) modifier inside the inner brackets, and then the key3 will be printed (or any, according to $c index) please note that having the (Pk) modifier in the inner brackets when run inside the function does not work at all, rather indexes single chars in the key/value retrieved (as mentioned in my first post) Am I missing something? thanks for your patience about my cascade posting ciao