这代码的问题在哪呢?不知道怎么修该了,大神,求救+_+
#!/bin/bash
read -t 30 -p "Please input number1:" number1
read -t 30 -p "Please input number2:" number2
read -t 30 -p "Please input a operator:" operator
if [ -n "$number1" -a -n "$number2" -a -n "$operator" ]
then
test1=$(echo $number1 | sed's/[0-9]//g' )
test2=$(echo $number2 | sed's/[0-9]//g' )
if [ -z "$test1" -a -z "$test2" ]
then
if [ "$operator" == '+' ]
then
result=$(($number1 + $number2))
elif [ "$operator" == '-' ]
then
result=$(($number1 - $number2))
elif [ "$operator" == '*' ]
then
result=$(($number1 * $number2))
elif [ "$operator" == '/' ]
then
result=$(($number1 / $number2))
else
echo "Please Enter a vaild sybul"
exit 10
fi
else
echo "Please Enter a number"
exit 11
fi
else
echo "Please Enter vaild number"
exit 12
fi
echo "$number1 $operator $number2:$resulte"
~
~