Subversion Repositories vgwhois

Rev

Rev 5 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/bin/bash
2
 
3
#
11 daniel-mar 4
#  VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
5 daniel-mar 5
#  Maintenance / Developer utilities
2 daniel-mar 6
#
5 daniel-mar 7
#  (c) 2012-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
2 daniel-mar 8
#
5 daniel-mar 9
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
2 daniel-mar 10
#
11
 
12
DIR=$( dirname "$0" )
13
 
4 daniel-mar 14
TESTCASES_LIST="$DIR/../../config/testcases.list"
15
 
2 daniel-mar 16
ARGS=()
17
 
18
shuffle() {
19
	# http://stackoverflow.com/a/5533586
20
	local i tmp size max rand
21
 
22
	# $RANDOM % (i+1) is biased because of the limited range of $RANDOM
23
	# Compensate by using a range which is a multiple of the array size.
24
	size = ${#ARGS[*]}
25
	max = $(( 32768 / size * size ))
26
 
27
	for ((i=size-1; i>0; i--)); do
28
		while (( (rand=$RANDOM) >= max )); do :; done
29
		rand=$(( rand % (i+1) ))
30
		tmp=${ARGS[i]} ARGS[i]=${ARGS[rand]} ARGS[rand]=$tmp
31
	done
32
}
33
 
34
while read f; do
35
	if [ -z "$f" ]; then
36
		continue;
37
	fi
38
 
39
	echo "$f" | grep -E "\s*^#" > /dev/null
40
	if [ $? -eq 0 ]; then
41
		continue;
42
	fi
43
 
44
	# Warum? "tld jp" wird dann zu "tld"
45
	# query="$( basename $f )"
46
	query="$f";
47
 
48
	ARGS+=("$query")
4 daniel-mar 49
done < "$TESTCASES_LIST"
2 daniel-mar 50
 
51
# TODO: does not work
52
#shuffle
53
 
54
"$DIR"/single $@ ${ARGS[@]}
55
exit $?