Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem with RANDOM and arrays



> 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