I'm trying to modify this script for error handling. I've 2 errors
#!/bin/bash
re='^[0-9]+$'
echo "Scegli l'operazione da eseguire tra addizione (+) sottrazione (-) e moltiplicazione (*)"
read operazione
until [ $operazione = + ] || [$operazione = - ] || [$operazione = *]
do
echo "L'opzione scelta non è corretta"
read operazione
done
echo "Ora scegli due numeri"
read numero[1] numero[2]
until [[ "$numero[1] =~ $re" ]] && [[ "$numero[2] =~ $re" ]]
do
echo "I numeri digitati non sono corretti"
read numero[1] numero[2]
done
echo "Il risultato è $((${numero[1]}$operazione${numero[2]}))"
~ ~ So the errors are:
./errori_matematica: line 8: [: too many arguments
./errori_matematica: line 8: [*: command not found
then
in the last while if I type for example f or g or anything character thas is not a number at the last expression I receive 0 or just the number I type (for example if i type 54 l and i choose + like operation in the exit i have 54) but i want error if the numbers are not correct. Thank you and sorry for my english ;)