Created
September 7, 2012 15:51
-
-
Save claylo/3667348 to your computer and use it in GitHub Desktop.
Are we there yet?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The author releases this code into the public domain. | |
# requires 'say' command. OS X is your friend | |
RANGE=90 | |
LOOPS=10 | |
count=0 | |
# Thanks, interwebs! | |
# http://rosettacode.org/wiki/Pick_random_element#Bash | |
rand() { | |
printf $(( $1 * RANDOM / 32767 )) | |
} | |
rand_element() { | |
local -a th=("$@") | |
unset th[0] | |
printf $'%s\n' "${th[$(($(rand "${#th[*]}")+1))]}" | |
} | |
# loop for a while | |
echo "looping $LOOPS times" | |
while [ "$count" -le $LOOPS ] | |
do | |
number=$RANDOM | |
let "number %= $RANGE" | |
let "count += 1" | |
the_voice=$(rand_element \ | |
Agnes \ | |
Albert \ | |
Alex \ | |
"Bad News" \ | |
Bahh \ | |
Bells \ | |
Boing \ | |
Bruce \ | |
Bubbles \ | |
Cellos \ | |
Deranged \ | |
Fred \ | |
"Good News" \ | |
Hysterical \ | |
Junior \ | |
Kathy \ | |
"Pipe Organ" \ | |
Princess \ | |
Ralph \ | |
Trinoids \ | |
Vicki \ | |
Victoria \ | |
Whisper \ | |
Zarvox) | |
say "are we there yet?" --voice "$the_voice" | |
echo "...asked $the_voice (loop $count, sleeping $number)" | |
sleep $number | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment