授权
cd /Users/lion/Downloads/shell-test-demos
chmod u+x *.sh
read_user_enter.sh
#!/bin/bash
printHelp() {
echo "1. hello"
echo "2. world"
echo "0. exit"
}
printHelp
number=""
while [ -z $number ]; do
read -p "enter a number: " number
if [ "$number" == "0" ]; then
exit 1
elif [ "$number" == "1" ]; then
echo "hello"
number=""
elif [ "$number" == "2" ]; then
echo "world"
number=""
else
printHelp
number=""
fi
done