This is supposed to be a simple bank script. Whenever I try the case construct options it wont work for the deposit option after typing the amount it just goes straight back into the menu, same with withdrawal option. Option 3 which should just display the balance amount doesn't echo anything. The exit option and the * option work fine. I've been debugging this for a few hours now and can't seem to find what it is. Can anyone here help me by pointing me in the right direction?
Thanks in advance.
# MENU
error_flag=0
balance=0
while true
do
if [ $error_flag -eq 0 ]
then
tput clear
echo "Welcome valued customer"
echo "Please choose from the following options:"
echo "1: Deposit "
echo "2: Withdrawal "
echo "3: Display balance "
echo "4: Quit "
fi
error_flag=0
echo " Please enter your choice>......."
read choice
case $choice in
1) printf "How much $ would you like to deposit?"
read deposit
((balance = $deposit + $balance))
printf "Your current balance is now $balance" ;;
2) echo "How much $ would you like to withdraw?" ;
read withdraw
(( withdraw=$withdraw /- $balance ))
echo "Your remaining balance is $balance dollars" ;;
3) echo "Your current balance is $balance dollars" ;;
4) echo "Thank you for banking with us"
exit 0 ;;
*) echo "Please only type the options given in the menu"
error_flag=1 ;;
esac
export balance
export deposit
export withdraw
done
exit 0