我在 bash shell 脚本中运行一个循环,直到按下某个键为止(Ctrl-C 对我来说总是很残酷)。尽管我使用 -s 选项read,但单个字符显示在终端中。为什么 -s 选项没有read达到我的预期!
until read -s -n 1 -t 0.01; do
echo -n "."
sleep .5 # actual script code goes here
done
echo
Run Code Online (Sandbox Code Playgroud)