Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: use of rand() in zsh



On 10/10/2022 8:27 PM, Clinton Bunch wrote:
On 10/10/2022 8:14 PM, Bart Schaefer wrote:
On Mon, Oct 10, 2022 at 4:38 PM Clinton Bunch <cdb_zsh@xxxxxxxxxxx> wrote:
Is there a reason that zsh goes out of the way (srand_deterministic) to
use the least random "random" function on modern Unix?
      The values of RANDOM form an intentionally-repeatable pseudo-random
      sequence; subshells that reference RANDOM will result in identical
      pseudo-random values unless the value of RANDOM is referenced or
      seeded in the parent shell in between subshell invocations.

This is e.g. so you aren't surprised by referencing $RANDOM inside
$(...) and getting a different result.

Well, I guess that explains why it uses rand, but doesn't really explain to me why you'd *want* this behavior.  I would expect to get a different value in a subshell than I got in the parent shell.  I'm supposedly looking for random numbers.

 I guess I side with OpenBSD who changed the default behavior of rand().


I wonder if it wouldn't be worthwhile to create a module that gave access to better sources of random numbers on the systems that support them.





Messages sorted by: Reverse Date, Date, Thread, Author