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

Re: use of rand() in zsh



> On 11/10/2022 13:35 Clinton Bunch <cdb_zsh@xxxxxxxxxxx> 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?
> >
> > This is e.g. so you aren't surprised by referencing $RANDOM inside
> > $(...) and getting a different result.
> >
> Doesn't zsleep_random's use of rand() break this predictability, or have 
> I just not studied the use of zsleep_random enough?

Yes, looks like any locking of history files will disturb the sequence.

That could be fairly easily fixed on a modern system by using rand_r here
--- history locking doesn't need high quality randomness, just
some sort of variation, so probably isn't worth reimplementing fully.

pws




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