"Richard L. Hamilton" wrote:
> 
> I trust this would become no more than a non-default option, selectable at
> run-time.

Erm, why ? Noone says that ${RANDOM} must be based on a pseudo-random
generator. I think that it may be nice to have a better source of
"randomness" (or better: more "secure") by default with the option to
fall-back to a pseudonumber generator if a specific seed value is
provided.

> A consistently-used pseudo-random number generator (even not a very good
> one), is useful insofar as one can rerun sequences by starting with the same
> seed; for debugging (as in replicating a problem) if nothing else.  Not to
> mention games like freecell that use the seed to represent a particular hand.

But this is still not portable. Scripts are mainly portable across
platforms but the output of ${RANDOM} should be unpredictable and
relying on a specific output sequence (or specific ${RANDOM} behaviour
in child&&parent proceses) based on one input seed value is IMO just
wrong as it changes between implementations of the underlying
pseudonumber generator and the implementation in the shell (for example
one problem is that ksh93 does not call |fork()| for "$( ... )" or "(
... )", therefore these instances influence the results generated of a
pseudonumber generator, too (otherwise I would expect that something
like $ RANDOM=666 ; (echo $RANDOM) ; echo $RANDOM) # prints identical
numbers)).

> What I think I'd like as much as what you describe is the option of using
> a better pseudo-random number generator; lrand48() comes to mind as
> both better and reasonably widely available.
> 
> Both of those  might be useful as options, but the current behavior should
> certainly remain the default.

I disagree in this case - the default should be the "best" source of
randomness available with the fallback option to use a pseudonumber
geneator if a seed value was provided. IMO that should be a compromise:
We get good random values by default and backwards-compatiblity to
scripts which use a seed value... :-)
... the tricky part is how we can implement a way to "reverse" the
switch to the pseudonumber generator. Write an empty string to ${RANDOM}
(e.g. RANDOM="" # ; however this would be little bit tricky as ${RANDOM}
is a integer and a writing strings to it should AFAIK result in an
error) ? Or write a special value like NaN or Inf+/Inf- to ${RANDOM} ?

> Finding a widely available _and_ thread-safe (on all platforms)
> pseudo-random number generator might get interesting...

Well, there is |rand_r()| which could be used instead.

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)

Reply via email to