31.6 Macro Conditionals: $?, $|, and $.Occasionally, it is necessary to test a macro to see whether a value has been assigned to it. To perform such a test, a special prefix and two operators are used. The general form is
if else endif $?x text1 $| text2 $. if x is defined if x is not defined
This expression yields one of two possible values:
The following, for example, includes
the configuration-file version
in the SMTP greeting message but does so only if
that version (in
O SmtpGreetingMessage=$j Sendmail ($v/
Here the parenthetical version information is expressed one
way if
($v/$Z)
but is expressed differently if
($v/generic)
The
else
part (
$?xtext1$|$. $?xtext1$.
Both of the preceding yield the same result. If
Note that it is
not
advisable to use the 31.6.1 Conditionals May NestV8 sendmail allows conditionals to nest. To illustrate, consider the following expression:
$?x $?y both $| xonly $. $| $?y yonly $| none $. $. This is just like the example in the previous section:
$?x text1 $| text2 $.
except that
text1 = $?y both $| xonly $. text2 = $?y yonly $| none $. The grouping when conditionals nest is from the outside in. In the following example, parentheses have been inserted to show the groupings (they are not a part of either expression):
Interpretation is from left to right.
The logic of the second line above is therefore this:
If both
The
sendmail
program does not enforce or check for balance
in nested conditionals. Each The depth to which conditionals may be nested is limited only by our ability to easily comprehend the result. More than two deep is not recommended, and more than three deep is vigorously discouraged. |
|