Some additional info: These don't work (they should return the same value, right?):
$ (RANDOM=1; echo $RANDOM) 21465 $ (RANDOM=1; echo $RANDOM) 22374 $ (RANDOM=1; echo $RANDOM) 6444 While all of these do: $ RANDOM=1; echo $RANDOM 16838 $ RANDOM=1; echo $RANDOM 16838 $ RANDOM=1; echo $RANDOM 16838 $ cat bla.sh #!/bin/bash RANDOM=1; echo $RANDOM $ ./bla.sh 16838 $ (./bla.sh) 16838 Ctrl+D (in another terminal) $ RANDOM=1; echo $RANDOM 16838 Is anyone looking into this? On Wed, 2 Mar 2005 14:15:41 +0200, zavandi <[EMAIL PROTECTED]> wrote: > Configuration Information [Automatically generated, do not change]: > Machine: i386 > OS: linux-gnu > Compiler: i386-redhat-linux-gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' > -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' > -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib > -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 > uname output: Linux localhost.localdomain 2.6.10-1.766_FC3 #1 Wed Feb > 9 23:06:42 EST 2005 i686 athlon i386 GNU/Linux > Machine Type: i386-redhat-linux-gnu > > Bash Version: 3.0 > Patch Level: 14 > Release Status: release > > Description: > Seems like $RANDOM never returns 0 in some conditions. "some > conditions" seem to be related to $RANDOM being executed in a > subshell, but I could be wrong here. > > Repeat-By: > This command works correctly, printing (usually) a few OKs: > > for ((i=0; i< 100000; i++)); do if [ $RANDOM -eq 0 ]; then > echo OK; fi; done > > But this other command _never_ prints anything: > > for ((i=0; i< 100000; i++)); do if [ $RANDOM -eq 0 ]; then > echo OK; fi; done | cat > > Neither does this command: > > (for ((i=0; i< 100000; i++)); do if [ $RANDOM -eq 0 ]; then > echo OK; fi; done) > _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash