sendmail: Should I use $*, $+ or $- ?
When writing a sendmail.mc rule, you can use some operators on the left hand side, like $- (match exactly one token), $+ (match one or more tokens) and $* (match zero or more tokens). You may find yourself in a situation where for example you want to use a certain delivery agent for some of your users. Normally you would write something like the following:
LOCAL_CONFIG Kmitsos btree -m -a.mitsos /etc/mail/mitsosusers LOCAL_RULE_0 : R$- < @ $=w . > $* $: $(mitsos $1 $) $3 R$- . mitsos $* $#mitsos $: $1
The above example seems to be correct, right? But what if you have a user in mitsosusers that contains a dot (.) in the user name (for example yiorgos.adamopoulos)? Because the . is a token separator (see the OperatorChars definition in your sendmail.cf), $- will not match the name. So the correct ruleset in this case is:
R$+ < @ $=w . > $* $: $(mitsos $1 $) $3 R$+ . mitsos $* $#mitsos $: $1
I got bitten by this sometime ago, and that is why I am sharing it.