Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: problem with RANDOM and arrays
- X-seq: zsh-workers 27593
- From: Chet Ramey <chet.ramey@xxxxxxxx>
- To: stephane_chazelas@xxxxxxxx
- Subject: Re: problem with RANDOM and arrays
- Date: Mon, 11 Jan 2010 17:14:00 -0500
- Cc: zsh-workers@xxxxxxx, chet@xxxxxxxxxxx
- In-reply-to: Message from stephane_chazelas@xxxxxxxx of Mon, 11 Jan 2010 22:01:37 +0000 (id <chaz20100111220137.GA15014@xxxxxxxxxxx>)
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Read-receipt-to: chet.ramey@xxxxxxxx
- References: <chaz20100111201312.GB3902@xxxxxxxxxxx> <chaz20100111205846.GE3902@xxxxxxxxxxx> <chaz20100111220137.GA15014@xxxxxxxxxxx>
- Reply-to: chet.ramey@xxxxxxxx
- Sender: Chet Ramey <chet@xxxxxxxxxxxxxxxxxx>
> Well no, actually it's the fact that "a" is previously unset
> that affects the behavior:
>
> ~$ unset a
> ~$ x=0; ((a[++x]++)); echo $x
> 1
> ~$ unset a
> ~$ a[1]=0
> ~$ a[2]=0
> ~$ x=0; ((a[++x]++)); echo $x
> 2
> ~$ unset a
> ~$ a[3]=0
> ~$ x=0; ((a[++x]++)); echo $x
> 2
>
>
> So the behavior is slighly worse than in bash or ksh93 (which
> consistently give 2 above).
Bash and ksh93 explicitly evaluate the subscript even if the variable is
unset, so any expected side effects happen. I got a bug report on this
a while back.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@xxxxxxxx http://cnswww.cns.cwru.edu/~chet/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author