The LHS

The LHS of any rule is compared to the current contents of the workspace to determine whether the two match. Table 18-1 displays a variety of special operators offered by sendmail that make comparisons easier and more versatile.

Table 18-1. LHS operators

Operator

§

Description or Use

$*

$*

Match zero or more tokens

$+

$+

Match one or more tokens

$-

$-

Match exactly one token

$@

$@

Match exactly zero tokens (V8 only)

$=

Section 22.2.1

Match any tokens in a class[6]

$~

Section 22.2.2

Match any single token not in a class

$#

$#

Match a literal $#

$|

$|

Match a literal $|

$&

Section 21.5.3

Delay macro expansion until runtime

[6] Class matches either a single token or multiple tokens, depending on the version of sendmail (Section 22.2).

The first three operators in Table 18-1 are wildcard operators, which can be used to match arbitrary sequences of tokens in the workspace. Consider the following rule, which employs the $- operator (match any single token):

R $-     fred.local

Here, a match is found only if the workspace contains a single token (such as tom). If the workspace contains multiple tokens (such as tom@host), the LHS does not match. A match causes the workspace to be rewritten by the RHS to become fred.local. The rewritten workspace is then compared again to the $-, but this time there is no match because the workspace contains three tokens (fred, a dot (.), and local). Because there is no match, the current workspace (fred.local) is carried ...

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.