簡體   English   中英

如何知道Bash讀取超時(-t)或無輸入(輸入)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM