[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Documentation: RANDOM=0 resets the seed
From: |
Olivier Mehani |
Subject: |
Documentation: RANDOM=0 resets the seed |
Date: |
Mon, 24 Jan 2011 14:53:12 +1100 |
User-agent: |
Mutt/1.5.18-muttng (2008-05-17) |
Hi,
I'm using Bash's $RANDOM variable to create repeatable sequences of
pseudo-random numbers. I used seeds >= 0, and noticed random
non-repeatable sequences for RANDOM=0, which I didn't expect given the
documentation.
Looking at the code, it appears that RANDOM=0 has a specific value,
which appears to be “seed not initialised,” and triggers an
initialisation on the next call. I think this characteristic has to be
made explicit in the documentation, to avoid bad surprises.
How about this hand made diff
RANDOM Each time this parameter is referenced, a random integer between
0 and 32767 is generated. The sequence of random numbers may be
- initialized by assigning a value to RANDOM. If RANDOM is unset,
- it loses its special properties, even if it is subsequently
- reset.
+ initialized by assigning a value larger than 0 to RANDOM. A
+ value of 0 would reset the seed to the current time at which the
+ next number is requested. If RANDOM is unset, it loses its
+ special properties, even if it is subsequently reset.
for the man page (and similar for the other formats)?
Please Cc me on any answer as I'm not subscribed to this list.
--
Olivier Mehani <shtrom@ssji.net>
PGP fingerprint: 4435 CF6A 7C8D DD9B E2DE F5F9 F012 A6E2 98C6 6655
pgpECyqHNX5qs.pgp
Description: Cryptographic signature
- Documentation: RANDOM=0 resets the seed,
Olivier Mehani <=