Subject: how to replace $RANDOM
To: NetBSD Users <netbsd-users@NetBSD.org>
From: Louis Guillaume <lguillaume@berklee.edu>
List: netbsd-users
Date: 03/21/2007 18:14:59
Hi,
I'm trying to fix the subversion-base package's dependency on $RANDOM.
It causes pkgsrc to complain about portability (rightfully so).
In this particular case, all I need is to generate a random integer.
Could probably even use the current process ID for this scenario, but
I'd like to know how to generate a `random' number from userland,
without having to write a program.
How can I get the same behaviour as $RANDOM in a portable way?
From the bash man page:
RANDOM Each time this parameter is referenced, a random integer between
0 and 32767 is generated. The sequence of random numbers may be
initialized by assigning a value to RANDOM. If RANDOM is unset,
it loses its special properties, even if it is subsequently
reset.
Louis