On Wed, Aug 23, 2017 at 01:16:56PM -0600, Aaron Toponce wrote: > Three POSIX-compliant shell functions that rely on no extra utilities > shuff () { > if [ $(command -v shuf) ]
Needs quotes. > shuffle -f /dev/stdin -p "$1" /dev/stdin is not POSIX-compliant. > else > awk 'BEGIN{ > "od -tu4 -N4 -A n /dev/urandom" | getline /dev/urandom is not POSIX-compliant. Then again, I don't believe there is *any* POSIX-compliant source of randomness available to shell scripts other than awk's srand and rand. Emulating /dev/urandom in awk is left as an exercise. ;-) > [ $(uname) = "SunOS" ] && FILE="/usr/dict/words" || > FILE="/usr/share/dict/words" It'd be better to list all the possible places the dict file may exist, and iterate through them until you find it, regardless of uname. Also, don't use all-caps shell variable names. All-caps names are reserved for special internal variables, and environment variables.