if()
if
Conditionally execute a group of commands.
if(expression) # then section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... elseif(expression2) # elseif section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... else(expression) # else section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endif(expression)
Evaluates the given expression. If the result is true, the commands in the THEN section are invoked. Otherwise, the commands in the else section are invoked. The elseif and else sections are optional. You may have multiple elseif clauses. Note that the expression in the else and endif clause is optional. Long expressions can be used and there is a traditional order of precedence. Parenthetical expressions are evaluated first followed by unary tests such as EXISTS
, COMMAND
, and DEFINED
. Then any binary tests such as EQUAL
, LESS
, LE