[flac-dev] [PATCH] Change test scripts shell to bash, to avoid lack of arithmetic support in dash, which is sh on Ubuntu 10.04
Jaren Stangret
sirjaren at gmail.com
Wed Mar 20 10:55:34 PDT 2013
>
> Your's is probably better and this is probably an improvement:
>
awk 'BEGIN { srand(); print int(rand() * 255 + 1) }'
>
Awk's rand seems to be seeded by the current epoch seconds, but in this
> case that doesn't matter.
Looks good to me. I'd even go as far as implementing your nanosecond
approach as the seed for AWK's 'srand()'. Maybe set up a tiny function to
use whenever we want a random integer:
random_int () {
awk \
-v nanosecond_seed=$(date +%N) \
'BEGIN {
srand( nanosecond_seed )
print int ( rand() * 255 + 1 )
}'
}
Then we can just call 'random_int' in place of $RANDOM...
On Wed, Mar 20, 2013 at 1:24 AM, Erik de Castro Lopo
<mle+la at mega-nerd.com>wrote:
> Jaren Stangret wrote:
>
> > Erik,
> >
> > I was thinking of doing this:
> > export MALLOC_PERTURB_=$(awk 'BEGIN { srand(); print int(rand() * 32767 %
> > 255 + 1) }')
> >
> > Or would you prefer using 'date'?
>
> Your's is probably better and this is probably an improvement:
>
> awk 'BEGIN { srand(); print int(rand() * 255 + 1) }'
>
> Awk's rand seems to be seeded by the current epoch seconds, but in this
> case that doesn't matter.
>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> flac-dev mailing list
> flac-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/flac-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20130320/69c088bd/attachment-0001.htm
More information about the flac-dev
mailing list