Paul Mundt, lethal at linux-sh dot org writes:
authorEric Andersen <andersen@codepoet.org>
Thu, 11 Mar 2004 13:34:24 +0000 (13:34 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 11 Mar 2004 13:34:24 +0000 (13:34 -0000)
commitef02f82bcf667ede9790a5de6aa78459529f29e4
tree626513aa59c95e061c7c40fbf6e4669981fb3a21
parentb7b3bda3ba0d3a49ac2ebbb422fe3bec99e2b0b9
Paul Mundt, lethal at linux-sh dot org writes:

Here's a follow-up replacement to the patch I sent earlier, this adjusts some
of the semantics of the dynamic variable setting. Namely, dynamic vars can hook
a set handler (which RANDOM uses to adjust the seed). They'll only lose their
dynamic status if they're unset.

I've used the same approach that bash does to come up with the random number,
mostly just for consistency.

For example:

$ echo $RANDOM
13759
$ echo $RANDOM
20057
$ echo $RANDOM
1502
$ export RANDOM=42
$ echo $RANDOM
24179
$ echo $RANDOM
2046
$ unset RANDOM
$ echo $RANDOM

$ export RANDOM=42
$ echo $RANDOM
42
$
shell/ash.c