UNIX for OpenVMS Users, Third Edition

The statements IF-THEN-ELSE-ENDIF, GOSUB-RETURN, CALL, and GOTO provide flow control in OpenVMS command procedures. The UNIX C shell also offers if and goto and the additional statements while, foreach, break, continue, switch, breaksw, and shift to control the logical flow of a shell script. The Korn and bash shells provide if, while, until, for, break, continue, case, select, and shift. As with DCL command procedures, all three shells allow you to exert flow control in response to error conditions (see Section 10.8.12).
The if statement provides a one- or two-way conditional branch. You can nest if statements, as the more complex examples in Section 10.11 show.
The two Korn shell forms show a syntax that allows the then keyword to appear on the same line as the expression, a convention some programmers use, but the examples show then on a separate line, which others find more understandable. Like the Korn shell, bash requires that the then keyword be a separate statement, separated by either a new line or a semicolon from the test condition. The same requirements hold for the fi keyword. Like the C and Pascal programming languages, Perl statements are not line-oriented, but rather require semicolon statement separators. Because of this, the programmer has a great deal of flexibility...