说我有以下内容:
echo "Would you like to blarg, or flarg?"
read -e ACT
if [ "$ACT" == "blarg" ]
then
echo "Go Blarg."
echo "Possible Blargs are Blah and Flah, or go back to the previous question."
read -e MARV
fi
if [ "$ACT" == "flarg" ]
then
echo "Go Flarg."
echo "Possible Flargs are Blah and Flah, or go back to the previous question."
read -e CARVE
fi
(more if statements following general pattern)
我需要知道怎样做back
来回答上一个问题(Blah或Flah)来自MARV
或CARVE
的答案,以及回到第一个(Flarg或Blarg)。
编辑:我实际上需要知道如何使用read
重新定义变量。男孩,我是否可以过度思考。
答案 0 :(得分:1)
你的意思是:
while ! [[ "${ACT-}" =~ [bf]larg ]]
do
read -e ACT
[...]
done