#!/bin/bash # This is my second ever script. It is to decide whether or not to have a drink. It asks the # user a series of questions to determine if it is safe for them to drink and if it is safe # flips a coin to make a final choice. clear echo "Welcome to Should I Have a Drink 1.0" echo # first I will ask if the user is already drunk echo "are you drunk?" select choice in yes yesh no quit; do case $choice in 'yes') echo "do you feel sick?" select sick in yes no; do case $sick in 'yes') echo "you are too drunk, do not have a drink!" exit ;; 'no') echo "are you an alcoholic?" select alcoholic in yes no; do case $alcoholic in 'yes') echo "go to an AA meeting!" exit ;; 'no') echo "flipping coin" coin=$(( 1+(`od -An -N2 -i /dev/random` )%(10-0+1) )) if [ "$coin" -gt "5" ]; then echo "have a drink! ^_^" exit else echo "don't have a drink" exit fi ;; esac done ;; esac done ;; 'yesh') echo "Go to bed!" exit ;; 'no') echo "do you feel sick?" select sick in yes no; do case $sick in 'no') echo "flipping coin" coin=$(( 1+(`od -An -N2 -i /dev/random` )%(10-0+1) )) if [ "$coin" -gt "5" ]; then echo "have a drink! ^_^" exit else echo "don't have a drink" exit fi ;; 'yes') echo "are you hungover?" select hung in yes no; do case $hung in 'yes') echo "are you an alcoholic?" select alcoholic in yes no; do case $alcoholic in 'yes') echo "go to an AA meeting!" exit ;; 'no') echo "hair of the dog: have a drink" exit ;; esac done ;; 'no') echo "curl up in bed and watch films, drinking will just make you sicker!" exit ;; esac done ;; esac done ;; 'quit') echo "Bye Bye" exit ;; esac done exit