Conditional structures: Difference between revisions

Content added Content deleted
imported>Tromp
(Conditional structures in BLC)
(→‎Else and elif: there really is no need to use semicolons if we plan on writing several lines anyway)
Line 8,030: Line 8,030:
There are optional <code>elif</code> (else if) and <code>else</code> clauses.
There are optional <code>elif</code> (else if) and <code>else</code> clauses.


<syntaxhighlight lang="sh">if test 4 -ge 6; then
<syntaxhighlight lang="sh">if test 4 -ge 6
echo '4 is greater than or equal to 6'
then echo '4 is greater than or equal to 6'
elif test 4 -lt 6; then
elif test 4 -lt 6
echo '4 is less than 6'
then echo '4 is less than 6'
else echo '4 compares not to 6'
else
echo '4 compares not to 6'
fi</syntaxhighlight>
fi</syntaxhighlight>