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

BashIf Statement

Bash Problem Overview


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?

Bash Solutions


Solution 1 - Bash

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

Solution 2 - Bash

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

Solution 3 - Bash

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

Solution 4 - Bash

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRogerView Question on Stackoverflow
Solution 1 - BashNicola MusattiView Answer on Stackoverflow
Solution 2 - BashManny DView Answer on Stackoverflow
Solution 3 - BashglglglView Answer on Stackoverflow
Solution 4 - BashhughesView Answer on Stackoverflow