#!/usr/bin/ksh auto="true" while getopts ch ob do case $ob in h) cat $HOME/bin/ghosthelp exit;; c) auto="";; esac done word="" ; rr="--" ; loop=0 ; clear tput cup 1 35 ; echo "G H O S T - by airbrick@armory.com - 1996" tput cup 2 35 ; echo "____________________________________________" tput cup 4 0 ; echo "Turn number: 1" ; echo "Current spelling:" tput cup 6 0 ; echo "Mode: " tput cup 6 18 ; if [ -n "$auto" ]; then echo "automatic" fi if [ ! -n "$auto" ]; then echo "challenge" fi while true do loop=`echo $loop+1 | bc` ; tput cup 4 18 ; echo $loop while true do tput cup 3 0 ; read "rr?Enter a letter: " tput cup 3 16 ; echo " " if [[ "$rr" = +([a-z]) ]]; then if [ ${#rr} -eq 1 ]; then break fi if [ "$rr" = "challenge" -a "$auto" = "" -a ${#word} -gt 1 ]; then accuse="true" break fi if [ "$rr" = "abort" ]; then break fi fi done if [ $rr = "abort" ]; then break fi if [ $rr != "challenge" ]; then tput cup 3 16 ; echo " " word=$word$rr ; rr="--" tput cup 5 18 ; echo $word if [ ${#word} -gt 2 ]; then if look -f $word | fgrep -ix $word > /dev/null; then tput cup 4 30 echo "You lose: '"$word"' is correctly spelled." break fi fi fi if [ -n "$auto" -o -n "$accuse" ]; then if ! look -f $word > /dev/null ; then tput cup 4 30 if [ ! -n "$accuse" ]; then echo "You lose: nothing begins with '"$word".'" break fi if [ -n "$accuse" ]; then echo "You lose: the challenge succeeded." break fi fi if [ -n "$accuse" -a ! -n "$def" ]; then tput cup 4 30 echo "You lose:"`look -f $word | wc -l`" word(s) begin with '"$word".'" break fi fi done tput cup 5 30 ; echo "Thanks for playing ghost." ; echo "" echo "________________________________________________________________________________" exit