返回bash中的前一个if语句

时间:2015-07-18 08:22:11

标签: macos bash

说我有以下内容:

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)来自MARVCARVE的答案,以及回到第一个(Flarg或Blarg)。

编辑:我实际上需要知道如何使用read重新定义变量。男孩,我是否可以过度思考。

1 个答案:

答案 0 :(得分:1)

你的意思是:

while ! [[ "${ACT-}" =~ [bf]larg ]]
do
    read -e ACT
    [...]
done