Linux – Binge : “done” unexpected (expecting “fi”)

Binge : “done” unexpected (expecting “fi”)… here is a solution to the problem.

Binge : “done” unexpected (expecting “fi”)

I get the following error when I try to run the script

Bash : "done" unexpected (expecting "fi")

I

tried bash and dash and I got the same error.

topip4="false"
topip6="false"
topurl="false"
for par in "[email protected]" ; do
    if [ "$par" == "-topip4" ] ; then
        topip4="true"
    else if [ "$par" == "-topip6" ] ; then
        topip6="true"
    else if [ "$par" == "-topurl" ] ; then
        topurl="true"
    fi
done

Solution

Change else if to elif.

Related Problems and Solutions