* More bash parameter syntax
@ 1998-12-12 6:41 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 1998-12-12 6:41 UTC (permalink / raw)
To: zsh-workers
`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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-12-12 6:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-12 6:41 More bash parameter syntax Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).