Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

I tried both bash and dash ,i get the same error.

topip4="false"
topip6="false"
topurl="false"
for par in "$@" ; do
    if [ "$par" == "-topip4" ] ; then
        topip4="true"
    else if [ "$par" == "-topip6" ] ; then
        topip6="true"
    else if [ "$par" == "-topurl" ] ; then
        topurl="true"
    fi
done
like image 353
SteveL Avatar asked Jun 18 '26 09:06

SteveL


1 Answers

Change your else if into elif.

like image 61
Matt K Avatar answered Jun 20 '26 21:06

Matt K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!