All rights reserved.
18.7 The RHS | 661
18.7 The RHS
The purpose of the RHS in a rule is to rewrite the workspace. To make this rewriting
more versatile, sendmail offers several special RHS operators. The complete list is
shown in Table 18-3.
18.7.1 Copy by Position: $digit
The $digit operator in the RHS is used to copy tokens from the LHS into the workspace.
The digit refers to positions of LHS wildcard operators in the LHS:
R $+ @ $* $2!$1
?†‘ ?†‘
$1 $2
Here, the $1 in the RHS indicates tokens matched by the first wildcard operator in
the LHS (in this case, the $+), and the $2 in the RHS indicates tokens matched by the
second wildcard operator in the LHS (the $*). In this example, if the workspace contains
A@B.C, it will be rewritten by the RHS as follows (note that the order is defined
by the RHS):
$* matches B.C so $2 copies it to workspace
! explicitly added to the workspace
$+ matches A so $1 adds it to workspace
The $digit copies all the tokens matched by its corresponding wildcard operator.
For the $+ wildcard operator, only a single token (A) is matched and copied with $1.
The ! is copied as is. For the $* wildcard operator, three tokens are matched (B.C), so
$2 copies all three. Thus, this rule rewrites A@B.C into B.C!A.
Table 18-3. RHS operators
RHS ?§ Description or use
$digit ?§18.7.1 on page 661 Copy by position.
Pages:
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163