lundi 6 avril 2015

In Bash, Why `then` is needed in the conditional constructs?

The conditional construct of if command looks like this:



if TEST-COMMANDS; then
CONSEQUENT-COMMANDS;
[elif MORE-TEST-COMMANDS; then
MORE-CONSEQUENTS;]
[else ALTERNATE-CONSEQUENTS;]
fi


And the loop construct of while command looks like this:



while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done


I was wondering why then is needed in if command but not in while command? Why couldn't it be ommited?


Aucun commentaire:

Enregistrer un commentaire