Bash - “fi ;;”有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7010830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 20:51:33  来源:igfitidea点击:

Bash - what's the use of "fi ;;"?

bashif-statement

提问by Roger

I have been searching everywhere for an explanation. Here's a real example taken from the apt-fast.sh script:

我一直在到处寻找解释。这是一个取自 apt-fast.sh 脚本的真实示例:

if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
    read ops
    case $ops in
     y) if apt-get install axel -y --force-yes
           then echo "axel installed"
        else echo "unable to install the axel. you are using sudo?" ; exit
        fi ;;
     n) echo "not possible usage apt-fast" ; exit ;;
    esac
fi

What's the use of "fi ;;"in the middle of the ifblock?

"fi ;;"中间有什么用if

回答by Nicola Musatti

ficloses the ifstatement, while ;;closes the current entry in the casestatement.

fi关闭if语句,同时;;关闭语句中的当前条目case

回答by Manny D

The fiis to close the if-block in the y)case statement and the ;;is used to end the y)case.

fi是关闭,如果块中的y)case语句和;;用于结束的y)情况下。

回答by glglgl

fiterminates the preceding if, while ;;terminates the y)case in the case...esac.

fi终止前面的if,而;;终止 中的y)情况case...esac

回答by hughes

ficloses the ifstatement opened 3 lines up. ;;closes the case opened by y).

fi关闭if语句打开 3 行。;;关闭由打开的案例y)