【发布时间】:2014-08-01 19:53:17
【问题描述】:
为什么如果“title”变量输入空值,“if”语句上的代码会一直循环,但是对于case语句,我的脚本会出错?
echo -n "Title :"
read title
if [ -z "$title" ]; then
echo "Please input a title"
while [[ -z "$title" ]] ; do
echo -n "Title: "
read title
done
fi
read author
case "$author" in
*[0-9,\""\!@#$%\(\)]*) echo "Please enter a name" ;;
while *[1-9,\""\!@#$%\(\)]*)"$author" ]] ; do
echo -n "author "
read author
esac
【问题讨论】:
标签: bash loops if-statement case