ZTS: Provide an alternative to shuf for FreeBSD

There was a shuf package but the upstream for the port has recently
disappeared, so it is no longer available.

Create a function to hide the usage of shuf. Implement using seq|random
on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9824
This commit is contained in:
Ryan Moeller
2020-01-09 12:31:17 -05:00
committed by Brian Behlendorf
parent 4abd7d80b2
commit 90ae48733c
5 changed files with 21 additions and 5 deletions
+15
View File
@@ -3934,3 +3934,18 @@ function faketty
script --return --quiet -c "$*" /dev/null
fi
}
#
# Produce a random permutation of the integers in a given range (inclusive).
#
function range_shuffle # begin end
{
typeset -i begin=$1
typeset -i end=$2
if is_freebsd; then
seq ${begin} ${end} | random -f -
else
shuf -i ${begin}-${end}
fi
}