bug-bash
[Top][All Lists]
Advanced

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

$RANDOM never returns 0 in some conditions


From: zavandi
Subject: $RANDOM never returns 0 in some conditions
Date: Wed, 2 Mar 2005 14:15:41 +0200

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)




reply via email to

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