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
.
Not all LHS operators need to be
referenced with a $
digit
in
the RHS. Consider the following:
R $* < $* > $* <$2>
Here, only the middle LHS operator (the second one) is
required to rewrite the workspace. So, only the
$2
is needed in
the RHS ($1
and
$3
are not
needed and are not present in the RHS).
Although macros appear to be operators in the LHS,
they are not. Recall that macros are expanded when
the configuration file is read (Macros in Rules on page 650). As a
consequence, although they appear as $
letter ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.