From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13676 invoked from network); 12 Dec 1998 06:54:50 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Dec 1998 06:54:50 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id BAA28116; Sat, 12 Dec 1998 01:42:52 -0500 (EST) Resent-Date: Sat, 12 Dec 1998 01:42:52 -0500 (EST) From: "Bart Schaefer" Message-Id: <981211224147.ZM23513@candle.brasslantern.com> Date: Fri, 11 Dec 1998 22:41:46 -0800 X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: More bash parameter syntax MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"IyNKC2.0.Ft6.i1XSs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4756 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu `info bash` sayeth: Arrays are assigned to using compound assignments of the form name=(value1 ... valueN) where each VALUE is of the form `[[SUBSCRIPT]=]'STRING. If the optional subscript is supplied, that index is assigned to; otherwise the index of the element assigned is the last index assigned to by the statement plus one. Indexing starts at zero. This syntax is also accepted by the `declare' builtin. Thus: bash$ foo=([1]=bar [3]=baz [2]=flip [0]=flop) bash$ echo ${foo[@]} flop bar flip baz I only wish this syntax didn't conflict with glob-pattern char classes. It'd be nice to use for associative arrays: assoc=([barney]=betty [fred]=wilma [bambam]=pebbles) instead of the currently-supported-if-you-have-the-right-patches typeset -A assoc assoc=(barney betty fred wilma bambam pebbles) BTW, I have been noodling with the ${(kv)assoc[(i)pat]} code, and I have [(i)pat] correctly searching the keys for pat rather than the values, but I haven't worked out how to either get the (kv) information either into or across getindex() (which parses everything inside the [ ] and then derefs it). Mainly I haven't decided how brave/inspired I feel to rework the params.c code into a more flexible division of labor. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com