我需要一些清晰度,如果我可以执行一个脚本循环,它将继续无限,除非有人在键盘上点击任何东西。
我只是希望脚本继续循环切换回显函数,直到按下一个键。
我真的不知道还有什么要写,或者如何解释这个更简单。
这是我的脚本,我觉得这样做会很好。
#!/bin/bash
act(){
sleep 1 #delay code to show message
clear
echo "no action taken" #first message
#some code to skip next line after a set amount of time
read int #read code for user input
act2 #go to next message
}
act2(){
sleep 1 #delay code to show message
clear
echo "still no action taken" #second message
#some code to skip next line after a set amount of time
read int #read code for user input
scan #go back to if statement
}
scan(){
if [ "$int" == "" ] || [ "$int" == 0 ] #scan if input is empty
then
act #load first message
else
echo "action was done" #States that input was not empty
fi
}
echo "Hit enter" #prompt
read int #read empty input
scan