Bash - what's the use of "fi ;;"?
Matthew Harrington
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
fiWhat's the use of "fi ;;" in the middle of the if block?
4 Answers
fi closes the if statement, while ;; closes the current entry in the case statement.
The fi is to close the if-block in the y) case statement and the ;; is used to end the y) case.
fi terminates the preceding if, while ;; terminates the y) case in the case...esac.
fi closes the if statement opened 3 lines up. ;; closes the case opened by y).