zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@math.gatech.edu
Subject: More bash parameter syntax
Date: Fri, 11 Dec 1998 22:41:46 -0800	[thread overview]
Message-ID: <981211224147.ZM23513@candle.brasslantern.com> (raw)

`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


                 reply	other threads:[~1998-12-12  6:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=981211224147.ZM23513@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).