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: Chet Ramey
Subject: Re: Problems when RANDOM without $ is used as an array index
Date: Tue, 12 Jan 2010 22:07:31 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 1/12/10 5:16 AM, Stephane CHAZELAS wrote:
> 2010-01-11, 17:42(-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.
>>
>> OK.  But everyone does it the same way.
> 
> Except for pdksh, mksh, posh, perl, C.

The three shells in your list are all variants of the same base.  It's
like using three different releases of bash.  The other two aren't
shells.  C is a reasonable comparison, but there are other differences
in how the languages are parsed and executed.

> I think by "everyone", you mean "AT&T ksh" and "zsh" or do you
> know any other shell or language that behaves like that?

I haven't done an extensive investigation.  It's not really a significant
issue.  It's important enough that bash, ksh, and zsh agree.  We don't
need more incompatibilities between the major shells.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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