I wanted to simulate a vending machine where you can buy things only if you throw 2€ inside.
It works as long as i only enter integer values, but if i enter a character or a float it suddenly stops to work. And throws an error that there is an integer expression expected.
read -p "Throw in money" x
echo ""
while [ $x -ne 2 ] ;
do
case $x in
0.5)
read -p "more money" z
x=$(($x + $z))
;;
1)
read -p "more money" z
x=$(($x + $z))
;;
1.5)
read -p "more money" z
x=$(($x + $z))
;;
"R")
echo "return x"
x=0
;;
?)
echo "enter something else!"
x=0
;;
esac
done
whileexpression