为什么以下脚本不能在bash中运行:
while [[ true ]]; do
read -t2 -n1 check
if [[ $check == "q" ]];then
echo "pressed"
read -n1
check=""
else
echo "not pressed"
fi
echo "Doing Something"
done
我正在使用最新的macOS和Terminal.app
答案 0 :(得分:0)
也许你想要这样的东西(bash版本4.3):
while [[ true ]]; do
read -t2 -N1 check
if [[ $check ]];then
echo "pressed"
if [[ "$check" == "q" ]]; then
break
fi
else
echo "not pressed"
fi
echo "Doing Something"
done
请看一下
$ echo "$BASH_VERSION"
打印。