[英]How to know whether the Bash read time-outed(-t) or no input(enter)
我需要比較我的輸入是否為null(超時)或輸入 ...
read -t3 ANS
if [ "$ANS" == "" ]; then
echo "input is null"
fi
當按下Enter鍵或等待超時時,兩個$ANS
始終為“”(空)。
看看$?
read
后-超時時將為1
,否則為0
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.