The following shell scripts pass POSIX compiance with posh(1)
on Debian. They
have also been tested in bash(1)
, ksh(1)
, and dash(1)
(which provides
/bin/sh
) on Debian.
Feedback of testing with other shells on other systems to target portability is greatly appreciated. I don't get notified of Gist comments, so reach out to me on Twitter instead.
Execute with an argument as a maximum random number, no bigger than 4294967296:
$ ./insecure-random.sh 100
81
$ ./secure-random.sh 100
17