#!/usr/bin/env bash
ran_num=$(( $RANDOM % 100 ))
min_num=0
max_num=100
read -p "请输入一个 1~100 之间的数字/Please enter a number from one to onehundred : " get_num
while true
do
if [[ ${get_num} =~ ^[0-9]+$ ]];then
if [[ ${get_num} -gt 100 ]];then
read -p "请输入一个 1~100 之间的数字/Please enter a number from one to onehundred : " get_num
continue
fi
if [[ ${get_num} == ${ran_num} ]];then
echo "BOOM!!!"
exit
fi
if [[ ${get_num} -lt ${ran_num} ]];then
min_num=${get_num}
read -p "数字范围 ${min_num} ~ ${max_num} 请输入: " get_num
fi
if [[ ${get_num} -gt ${ran_num} ]];then
max_num=${get_num}
read -p "数字范围 ${min_num} ~ ${max_num} 请输入: " get_num
fi
if [[ ${get_num} -gt ${max_num} ]];then
read -p "数字范围 ${min_num} ~ ${max_num} 请输入: " get_num
fi
else
read -p "请输入一个 1~100 之间的数字/Please enter a number from one to onehundred : " get_num
fi
done