Bash - what's the use of “fi ;;”?

你说的曾经没有我的故事 提交于 2020-06-07 08:15:10

问题


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

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 if block?


回答1:


fi closes the if statement, while ;; closes the current entry in the case statement.




回答2:


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




回答3:


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




回答4:


fi closes the if statement opened 3 lines up. ;; closes the case opened by y).



来源:https://stackoverflow.com/questions/7010830/bash-whats-the-use-of-fi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!