Rev 5 | Blame | Last modification | View Log | RSS feed
#!/bin/bash
#
# VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
# Maintenance / Developer utilities
#
# (c) 2012-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
#
# License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
#
DIR=$( dirname "$0" )
TESTCASES_LIST="$DIR/../../config/testcases.list"
ARGS=()
shuffle() {
# http://stackoverflow.com/a/5533586
local i tmp size max rand
# $RANDOM % (i+1) is biased because of the limited range of $RANDOM
# Compensate by using a range which is a multiple of the array size.
size = ${#ARGS[*]}
max = $(( 32768 / size * size ))
for ((i=size-1; i>0; i--)); do
while (( (rand=$RANDOM) >= max )); do :; done
rand=$(( rand % (i+1) ))
tmp=${ARGS[i]} ARGS[i]=${ARGS[rand]} ARGS[rand]=$tmp
done
}
while read f; do
if [ -z "$f" ]; then
continue;
fi
echo "$f" | grep -E "\s*^#" > /dev/null
if [ $? -eq 0 ]; then
continue;
fi
# Warum? "tld jp" wird dann zu "tld"
# query="$( basename $f )"
query="$f";
ARGS+=("$query")
done < "$TESTCASES_LIST"
# TODO: does not work
#shuffle
"$DIR"/single $@ ${ARGS[@]}
exit $?