bug-bash
[Top][All Lists]
Advanced

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

Seeding $RANDOM in a subshell


From: Chris F.A. Johnson
Subject: Seeding $RANDOM in a subshell
Date: Thu, 13 Jan 2005 22:24:08 -0500 (EST)


   On various platforms, with versions of bash from 1.14 to 3.0, I
   get:

$ RANDOM=1234567890; echo $RANDOM
2599
$ RANDOM=1234567890; echo $RANDOM
2599

   That's as it should be. But when I put that in a subshell (2.05b
   and 3.00):

$ ( RANDOM=1234567890; echo $RANDOM )
18681
$ ( RANDOM=1234567890; echo $RANDOM )
20498
$ ( RANDOM=1234567890; echo $RANDOM )
22315

   Bash 1.14 (as well as pdksh and ksh93) produces the same number
   every time.

--
        Chris F.A. Johnson                      http://cfaj.freeshell.org
        =================================================================
                Everything in moderation -- including moderation




reply via email to

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