Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Associative Arrays
- X-seq: zsh-users 8094
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Associative Arrays
- Date: Fri, 22 Oct 2004 08:07:13 -0700 (PDT)
- Cc: Nikolai Weibull <zsh-users-list@xxxxxxxxxxxxx>
- In-reply-to: <20041022123233.GF1720@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20041020195348.GJ11322@xxxxxxxxxxxxxxxxxx> <20041021110526.GE1740@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <20041021123835.GF9224@xxxxxxxxxxxxxxxxxx> <Pine.LNX.4.61.0410210900110.14956@xxxxxxxxxxxxxxxxxx> <20041022123233.GF1720@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: zsh-users@xxxxxxxxxx
On Fri, 22 Oct 2004, Stephane Chazelas wrote:
> On Thu, Oct 21, 2004 at 09:40:14AM -0700, Bart Schaefer wrote:
> [...]
> > local -A named; set -A named "$@"
> [...]
>
> That's not correct as "$@" may have "-x"/"-e" like elements.
You'd be right if we weren't talking about zsh. From the doc for "set":
The behaviour of arguments after -A NAME or +A NAME depends on
whether the option KSH_ARRAYS is set. If it is not set, all
arguments following NAME are treated as values for the array,
regardless of their form. If the option is set, normal option
processing continues at that point; only regular arguments are
treated as values for the array. This means that
set -A array -x -- foo
sets array to `-x - foo' if KSH_ARRAYS is not set, but sets the
array to foo and turns on the option `-x' if it is set.
> ksh has:
>
> set -A named -- "$@"
>
> it doesn't seem to work in zsh 4.2.0.
See above.
> named=("$@")
>
> is OK though.
I'll agree it's better because it doesn't vary with KSH_ARRAYS.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author