jeudi 27 avril 2017

Bash correct (?) if statement not executing properly

I am sourcing the shell script of a software but I keep receiving the following error:

>source thefile.sh
'else' builtin not inside of if block

I've checked the theoretically erroneous block and I can't find anything wrong with the structure

if [ condition ]
then 
if [ condition2 ]
then
dostuff
else
dostuffagain
fi
else # this is the else which generates the error
stuffstuffstuff
fi

I can't see anything wrong with it: it's a nested if/then and every if is terminated by it's own fi. Why the shell gets upset about it??

Aucun commentaire:

Enregistrer un commentaire