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

Re: use of rand() in zsh



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.




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