bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems when RANDOM without $ is used as an array index


From: DennisW
Subject: Re: Problems when RANDOM without $ is used as an array index
Date: Mon, 11 Jan 2010 15:16:25 -0800 (PST)
User-agent: G2/1.0

On Jan 11, 3:53 pm, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:
> 2010-01-11, 15:59(-05), Chet Ramey:
> [...]> Think of it as
>
> > x = $(( RANDOM%6+1 + RANDOM%6+1 ))
> > y = dice[x]
> > dice[RANDOM%6+1 + RANDOM%6+1] = y + 1
> > return y
>
> [...]
>
> I would still consider that a bug.
>
> I don't think anyone would expect x to be incremented by 2 in a[++x]++
> and it doesn't in any other language I know (except AT&T ksh and
> zsh (under some circumstances)).
>
> --
> Stéphane

It's definitely a gotcha.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]