Re: Noisy CDPATH breaks variable construction

2010-01-11 Thread Chet Ramey
On 1/11/10 12:30 PM, Dams wrote: > Bash Version: 4.0 > Patch Level: 35 > Release Status: release > > Description: > > CDPATH makes the `cd' primitive quite verbose enough to break > some scripts, and it's also breaking the bourne compatibility. The last time this came up, I wrot

Noisy CDPATH breaks variable construction

2010-01-11 Thread Dams
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'

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

2010-01-11 Thread DennisW
On Jan 11, 3:53 pm, Stephane CHAZELAS 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

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

2010-01-11 Thread 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. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

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

2010-01-11 Thread Stephane CHAZELAS
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

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

2010-01-11 Thread Stephane CHAZELAS
2010-01-11, 14:26(+00), Stephane CHAZELAS: > 2010-01-9, 06:23(-06), den...@netstrata.com: > [...] >> This produces the correct distribution of dice values for two six-sided dice: >> >> $ unset dice; for i in {1..1}; do ((dice[$RANDOM%6+1 + >> $RANDOM%6+1]++)); done; echo "${di...@]}" >> 290

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

2010-01-11 Thread Chet Ramey
On 1/11/10 9:26 AM, Stephane CHAZELAS wrote: > 2010-01-9, 06:23(-06), den...@netstrata.com: > [...] >> This produces the correct distribution of dice values for two six-sided dice: >> >> $ unset dice; for i in {1..1}; do ((dice[$RANDOM%6+1 + >> $RANDOM%6+1]++)); done; echo "${di...@]}" >> 29

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

2010-01-11 Thread Stephane CHAZELAS
2010-01-9, 06:23(-06), den...@netstrata.com: [...] > This produces the correct distribution of dice values for two six-sided dice: > > $ unset dice; for i in {1..1}; do ((dice[$RANDOM%6+1 + $RANDOM%6+1]++)); > done; echo "${di...@]}" > 290 582 837 1130 1375 1635 1315 1126 845 574 291 > > The