The LHS

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

Table 18-2. LHS operators

Operator

§

Description or use

[a]

$*

$* on page 681

Match zero or more tokens.

$+

$+ on page 679

Match one or more tokens.

$-

$- on page 679

Match exactly one token.

$@

$@ on page 673

Match exactly zero tokens (V8 only).

$=

Matching Any in a Class: $= on page 863

Match any tokens in a class.[a]

Matching Any Token Not in a Class: $~ on page 864

Match any single token not in a class.

$#

$# on page 680

Match a literal $#.

$|

$| on page 682

Match a literal $|.

$&

Use Value As Is with $& on page 793

Delay macro expansion until runtime.

[a] a Class matches either a single token or multiple tokens, depending on the version of sendmail (Access Classes in Rules).

The first three operators in Table 18-2 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 ...

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.