From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19326 invoked by alias); 2 Nov 2015 21:05:25 -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: 20880 Received: (qmail 473 invoked from network); 2 Nov 2015 21:05:23 -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_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern_com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=trvIdLpRmYID8CYzL7gyRt2G49UfAApgb+vwWZlM7dc=; b=K+cSZE3c6ZISIl63NGSBMxX5liTSO53f7X1q3qB45TyOevlYA/Gl4YH24XMDFITOWI rI074GEsrVIvqC4zCPUGUEYSHhmQXoSDe3APQ8BmDzgPsLUBoQjLGdN1iagBQWvWNPkx R8PlaSh49GdQ2PDCfMWqblzw2QHOWhXbcSIfAIohXQ/UllyYMBwUYcMXyeA1FrlfFZDC QlSrtq008xJ3ZMspVmPbpXW2U/mTMYUnRqxUdO0g1eL1LpC3EHVa5AezTO8RC8InwL0N 0UpctT3cF/dS0R4eHqXDLMBQ3Ecbsfd9y8eCUAtQImOTzxaptlYJ/s45+xazAktcLXGJ MXqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=trvIdLpRmYID8CYzL7gyRt2G49UfAApgb+vwWZlM7dc=; b=CsuoLN+kzLHDawF23hmr+h0mrrKQahn3hlFpCpc63Ll9aD0GRqIR6QZKlud4WcCMkW pGQixDOaUUsaZZjMymU/bMqgrj1h0RBgrXf8C6GPu8fyPxtUGKXGY8uGVxWe+FHUGD1B sO+qWAubBx8c90TzKHc+HKA2XSjNzw3UFge2+x3mr4i8StpN5cJ+FRvocnX1YShKf6nl EOm2jQcZj2LS3JX/fDY1LhYTgH8R9xSSolOvSe0StiV2FoBUcTLJ+n21C6v3HWnhQ883 OT2eZsjg6IwzVFvtEBUp8mqPQCYZBWxsJQ4PNpnRRrEFGX0dPKedhR1QavtUtrQkLBr0 2OTQ== X-Gm-Message-State: ALoCoQmpNnJZ1a5ZCOYNoSiRQ7CgeANgsMnh9UqD5E6LVtIBVAr5jtUm3+wsRIM98qPzlFyHjgL4 X-Received: by 10.60.40.66 with SMTP id v2mr16645820oek.12.1446498321548; Mon, 02 Nov 2015 13:05:21 -0800 (PST) From: Bart Schaefer Message-Id: <151102130518.ZM17830@torch.brasslantern.com> Date: Mon, 2 Nov 2015 13:05:18 -0800 In-Reply-To: <5637AC27.8010007@eastlink.ca> Comments: In reply to Ray Andrews "Re: easy calling of associative array?" (Nov 2, 10:32am) References: <56369C7B.2030604@eastlink.ca> <1237641446422150@web6m.yandex.ru> <5636B333.8060300@eastlink.ca> <151101190842.ZM16752@torch.brasslantern.com> <5636D99F.2030807@eastlink.ca> <151101225100.ZM16882@torch.brasslantern.com> <563784B5.3040901@eastlink.ca> <151102082808.ZM17640@torch.brasslantern.com> <5637AC27.8010007@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: easy calling of associative array? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 2, 10:32am, Ray Andrews wrote: } Subject: Re: easy calling of associative array? } } On 11/02/2015 08:28 AM, Bart Schaefer wrote: } > } > set_v () { } > typeset -g "${1}[$2]=$3" # quotes so [ ] isn't globbing } > } } } I've never seen 'typeset' used to refer to anything but a simple } variable. In the above, set_v ary idx val is going to invoke typeset -g ary[idx]=val because $1 $2 $3 are all expanded after parsing and before calling the typeset command. (Zyx has pointed out the lack of robustness.) Note that it is not affecting any positional parameters, they're all long gone (replace by their values) before typeset begins. } I note that the above does not work without the 'typeset -g' so what } does that accomplish? Ordinarly "typeset" inside a function body behaves like "local". The -g option tells it not to do that, so that the name "ary" is taken to come from the calling context instead of the current function context. } BTW, as a point of list etiquette: Responding to most posts I let my } lines wrap } but resonding to yours, which seem to alway have fixed line width, I try to } match that style, but looking at the returned posts from the list, they } sometimes } sproing badly. Should I try to keep to your width, or just let lines wrap? The above is what your text would look like if I didn't run it through a reformatter. It Used To Be that everyone assumed text should be folded to be readable on an 80-column display, which, as a guy still using the email program I wrote myself 20 years ago, I still do. Then along came HTML format email, and everybody assumed text should never be wrapped at all (let the reader's UI deal with it). Except there's still this pesky thing about mailing lists preferring plain text, so we end up with a hypbrid where text as you write it is folded to be readable at whatever your display width is set, but then it gets re-folded to 80 when you send it -- except that it also keeps any real newlines you entered, so if you were actually trying to make it look nice, it ends up like the above instead. Exactly what you SHOULD do depends on what you're using to write your email. In Thunderbird you should probably put literal line breaks only at the ends of paragraphs, and let it wrap other stuff as it wills.