Name
$~
Synopsis
When trying to match tokens in the workspace to members of a class,
it is possible to invert the logic of a match. The
$~
operator instructs
sendmail to consider any single token that is
not in the class to be a match. For example, consider the following
rule:
R $+ < @ $* . $~{PseudoDomains} > $# relay $@ mailhub $: $1 <@ $2.$3>
Here, the workspace is expected to hold a focused address (such as
gw@<faxhost.fax>). The
$~{PseudoDomains}
expression causes
sendmail to look up the top-level domain
(suffix) part of the address (the fax) in the
class {PseudoDomains}
. If that suffix is absent
from that class, a match is made and the workspace is rewritten by
the RHS to relay the mail to the mailhub
machine.
If the suffix (fax
) is found in the
{PseudoDomains}
class, the LHS does not match, and
subsequent rules will handle the address, perhaps to forward the
message to a special fax-handling host.
Class macros in general are described in Chapter 22, and the $~
operator in
particular is described in full in Section 22.2.2. Note
that the $~
operator can be used only on the LHS
of rules, and can be referenced by an RHS
$
digit
operator.
Get Sendmail, 3rd 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.