Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: problem with RANDOM and arrays
- X-seq: zsh-workers 27592
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: problem with RANDOM and arrays
- Date: Mon, 11 Jan 2010 22:01:37 +0000
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=mHaLauzEle1Dafwm+HqNRW0UF10mUpFIkSGeqdHvieetN+E2sE5o3GwXBHDZI0sAD3Dx044G1uktkl4m7tdi77GN1vnTnJ1/Q48Czdk1in6KQ6OEbvsuaHi3sxNJtCFHz1jUcAFTJn/An3A3B1t08AiVDHrC8a3uhpKbhRIjJos= ;
- In-reply-to: <chaz20100111205846.GE3902@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>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <chaz20100111201312.GB3902@xxxxxxxxxxx> <chaz20100111205846.GE3902@xxxxxxxxxxx>
2010-01-11 20:58:46 +0000, Stephane Chazelas:
> 2010-01-11 20:13:12 +0000, Stephane Chazelas:
> [...]
> > Similar problem:
> >
> > $ x=0; ((a[++x]++)); echo $x
> > 2
> >
> > All the +=, -=, *=... operators are also affected.
> [...]
>
> Strange, their must be something in my .zshrc that affects the
> behavior as I get:
>
> $ zsh -c 'x=0; ((a[++x]++)); echo $x'
> 1
[...]
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).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author