[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
The Ugliest American Bash Script
From: |
cLIeNUX user |
Subject: |
The Ugliest American Bash Script |
Date: |
Sat, 08 May 2004 19:58:58 -0000 |
doballot () {
clear
# Squeal if prez is abstain
if test "$prez" = "abstain" ; then
echo "
You have selected the q option to finalize your ballot editing session,
but you haven't chosen a candidate for President of the United States. You
may want to ask for assistance before hitting another key, unless you
actually intend to actively abstain from voting for President, which this
system asks you about because you didn't have to come to the poll to do
that.
"
waitenter
fi
# do an Are You Sure?
echo "
This is it. The next time you hit ENTER with no other keys your final
official ballot will be printed out and your votes will be added to the
electronic unofficial tally. If you aren't really ready to finalize
editing your ballot hit n before hitting ENTER .
"
read notsure
if test "$notsure" ; then
notsure=
else # print and tally
notsure=
hasnotvoted=
echo -en "\007" # beep the PC beeper. Korny.
Tally
waitenter # DELETE ME ON ELECTION DAY
printballot # > /dev/lp0 UNCOMMENT ME ON ELECTION DAY
waitenter # DELETE ME ON ELECTION DAY
clear
echo "
Thank you for participating in the democratic process of the United States
of America and the Second Congressional District of East Jesus Wyoming.
When your ballot is printed take it to the ballot box and insert the
ballot in the box.
"
sleep 5
fi
}
perVoter () { # per-voter top loop
while test "$hasnotvoted" ;do
voterUID=$RANDOM$RANDOM
clear
echo "
You can change your vote for any item until you select the q item, which
will ask for confirmation, and then your official ballot printed out and
the electronic copy of your vote will be finalized. Your actual vote
becomes official when you place the printed ballot in the ballot box.
p President
v Vice President
s Senator
c Congressman
r Review your votes so far
o Start over; reset all your votes to abstain
q print your ballot, backup tally your votes and quit
Hit an option letter from the left column and hit ENTER .
"
read maini
case $maini in
p|P) president ;;
v|V) local ;;
s|S) senator ;;
c|C) congressman ;;
r|R) checkem ;;
o|O) allabstain ;;
q|Q) doballot ;;
*) halp ;;
esac
done
}
writein () {
# needs to be a loop
clear
echo"
Type in your write-in selection and hit ENTER
"
read $wrotein
clear
echo "You have written in" $wrotein
}
checkem () {
clear
echo "
Your current votes...
United States of America
"
printballot
waitenter
}
newvcode () { # Simple gizmo to problematicize repeat voting
# Note to poll site proctors...
# change fluib and trUb to something unique to your
# polling place and change them per election.
if test "$vcode" = "fluib" ; then
vcode=trUb
else
vcode=fluib
fi
}
allabstain () {
prez=abstain
veep=abstain
congressman=abstain
senator=abstain
# add local offices here if any
}
waitenter () {
echo "
Hit Enter to continue
"
read junkvariable
}
president () {
clear
echo "
President of the United States of America
b George Walker Bush Republican Party
k John Forbes Kerry Democratic Party
w write in a vote
a abstain, no vote for this office
Hit an option letter from the left column and hit ENTER .
"
read fedi
case $fedi in
b|B) prez="George Walker Bush" ;;
k|K) prez="John Forbes Kerry" ;;
a|A) prez=abstain ;;
w|W) writein
prez=$wrotein ;;
*) halp ;;
esac
}
Tally () { # spaces are tabs
echo $voterUID" "$prez ## >> tally UNCOMMENT ME ON ELECTION DAY
echo $voterUID" "$veep ## >> tally UNCOMMENT ME ON ELECTION DAY
echo $voterUID" "$senator ## >> tally UNCOMMENT ME ON ELECTION DAY
echo $voterUID" "$congressman ## >> tally UNCOMMENT ME ON ELECTION DAY
}
printballot () {
echo "
$voterUID
President $prez
Vice President $veep
Senator $senator
Congressman $congressman
"
}
halp () { # keep factored out in case candidates grow into a tree
clear
echo "
Your input doesn't match any of the menu option index letters. That's a
problem for this system. Please use the letters shown to select menu
items. I will send you back to the main menu when you hit the ENTER key,
but if that doesn't make sense you may wish to seek assistance from a poll
monitoring person.
Hit the ENTER key to return to the main menu.
"
}
vcodehint () {
if test $vcode = trUb ; then
echo "
TTTTTTTTTTT
TTTTTTTTTTT
TT
TT
TT
TT
TT
TT
"
else
echo "
FFFFFFFFFF
FFFFFFFFFF
FF
FF
FFFFfF
FFFFFf
FF
FF
FF
FF
"
fi
}
Main () { # top endless loop of voter interface
# ctrl&C and so on should be disabled here in the real deal
export prez veep senator congressman
vcode=fluib
while true ;do # i.e. always
voted= # clear $voted toggle
allabstain
clear
vcodehint
echo "
Please type in your voter key and hit ENTER
"
read vcodeTry
if test "$vcodeTry" = "$vcode" ; then
newvcode
hasnotvoted=true
perVoter
else
echo -en "\007" # beep the PC beeper. Korny.
fi
done
} # end of Main
echo "
divehumble, opposite of Liebold
Unix shell script to serve as electronic polling aid for democratic
political elections.
initial sketch Rick Hohensee April 2004
Works on cLIeNUX (Linux, GNU Bash shell) on any recent-model IBM-style PC.
This file is a valid unix shell script, i.e. a computer program.
Korny means this is probably a dependancy on a Korn-style shell or GNU
Bash.
Localization of this script may involve changing some text, adding some
candidates, removing the Senator option, and other simple modifications.
Avoid changing the logic of Main and perVoter if at all possible.
" > /dev/null
- The Ugliest American Bash Script,
cLIeNUX user <=