$+

Match one or more tokens LHS operator

The $+ operator is very handy when you need to match at least one token in the workspace. For example, recall that the host part of an address containing zero tokens is bad, but one containing one or more tokens is good:

george@               ← zero tokens is bad
george@wash           ← one token is good
george@wash.dc.gov    ← many tokens is good

A rule that seeks to match the host part of an address might look like this:

 R $- @ $+            $: $1 < @ $2 >

Here, the LHS matches any complete address—that is, an address that contains a user part that is a single token (such as george), an @ character, and a host part that is one or more tokens (such as wash or wash.dc.gov).[258] Any address that matches is rewritten by the RHS to focus on the host part. Focusing an address means to surround the host part in angle braces. Thus, for example, george@wash will become george<@wash>.

Note that the $+ operator can be used only on the LHS of rules, and can be referenced by a $digit operator on the RHS.

[258] * Note that this simple example will not match more complex user parts, such as george+nospam or bob.smith. Examine the sendmail.cf file to see how more complex user parts can be handled.

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.