sendmail ruleset ルール セット

An Address Rewriting Rule
The core of sendmail’s address rewriting capabilities is based on the idea of rules and rulesets. An individual address rewriting rule is a simple if ... then ... statement. If the address matches the Left Hand Side (LHS) pattern, then it is rewritten into the Right Hand Side (RHS) pattern. These rules are collected into rulesets which can be considered to be sub-routines. Different rulesets have different functions: some are called directly by sendmail, some are called by sendmail’s mailers, some do specific types of address rewriting or address cleanup.

An address rewriting rule has 2 or optionally 3 fields separated by tabs:

R	LHS	<one or more tabs>	RHS	<optionally one or more tabs>	Optional comment field
If		Then
Here is an example rule:
R	$+ @ foo.com		$1 @ bar.com		user@foo.com -> user@bar.com

http://www.harker.com/sendmail/rules-overview.html

以上はそれほど難しくないですが、問題は、ルールコマンドです。

R$*        $: $>Parse1 $1       final parsing

lhs が $* , rhs が $: $>Parse1 $1 , comment がfinal parsing でそれらの間は「タブ文字」でなければなりません。ここをいい加減にすると動作がおかしくなります。OperatorChars=.:%@!^/[]+空白文字 を分割文字として、入力テキストをトークンに分割するのが sendmail の基本です。

上のコマンドは、$* で、0個以上のトークンと一致つまり lhs がなんでも rhs に変換の意味で、そのrhs は、$: 「一度だけ書き換え」で、$>Parse1 「Parse1 ルールセットを呼び出し」をその引数 $1 ( この場合は、入力をそのまま)として行った結果を次の行のルールコマンドに渡すという意味ですね。