From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2847 invoked by alias); 1 Nov 2015 23:43:07 -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: 20867 Received: (qmail 9703 invoked from network); 1 Nov 2015 23:43:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=hFxs0f5JAArYXmzDxhrHQA==:117 a=hFxs0f5JAArYXmzDxhrHQA==:17 a=IkcTkHD0fZMA:10 a=eIXcHQlEuge650165doA:9 a=QEXdDO2ut3YA:10 Message-id: <56369C7B.2030604@eastlink.ca> Date: Sun, 01 Nov 2015 15:12:59 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: Zsh Users Subject: easy calling of associative array? Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit test () { eval "baz=\$${1}[key1]" echo $baz eval "foo=\$${1}[key2]" echo $foo ... } If I want to pass the name of an associative array to a function via "$1" and then work with it's keys, the above succeeds but it's sure laborious. Is there some way to do the eval just once? So that I can end up doing: if [ "xyz[key1]" = '1' ]; then ... ... as I experiment, there seems to be no way of replacing 'xyz' with any expression that will do the job without needing eval's help every time, but I'll bet there's a way.