1

man procmailrc says:

variablename ?? Match the remainder of this condition against the value of this environment variable (which cannot be a pseudo variable). A special case is if variablename is equal to B, H, HB or BH; this merely overrides the default header/body search area defined by the initial flags on this recipe.

When using the ?? operator for the special case mentioned, does the "override" of the default flags persist only for this condition or for the entire rest of the recipe?

For example, if I specify

:0 H
* ^To:.*recipient
* B ?? tribbles
* ^From:.*space

will the From condition be tried against the Body because of the preceding line's override, or do the flags revert to their initial condition (H) after the override line ends?

dg99
  • 2,642

1 Answers1

2

The override persists only for the condition in which it is defined. Here's a slightly-altered experiment to demonstrate:

pm-test.rc

:0 H
* ^To:.*recipient
* B ?? tribbles
* space
mailbox

test-mail.txt

From: space-alert@storage.com
To: recipient@local.net

Your storage locker is overflowing with
tribbles.  Please clean it out.

Note that the word "space" appears only in the headers of the above message.

test-mail2.txt

From: alert@star.fleet
To: recipient@local.net

We're having some trouble with
tribbles at our space station.

Note that the word "space" appears only in the body of the above message.


If the B override does not expire at the end of its condition, pm-test.rc should succeed on the second message because "tribbles" is in the body and "space" is (only) in the body.

% procmail VERBOSE=on DEFAULT=/dev/null MAILDIR=/tmp pm-test.rc < test-mail2.txt

procmail: Match on "^To:.*recipient"
procmail: Match on "tribbles"
procmail: No match on "space"
procmail: Assigning "LASTFOLDER=/dev/null"

The recipe does not succeed.

Conversely, if the B override does expire at the end of its condition, pm-test.rc should succeed on the first message because "tribbles" is in the body and "space" is (only) in the headers.

% procmail VERBOSE=on DEFAULT=/dev/null MAILDIR=/tmp pm-test.rc < test-mail.txt

procmail: Match on "^To:.*recipient"
procmail: Match on "tribbles"
procmail: Match on "space"
procmail: Assigning "LASTFOLDER=mailbox"

The recipe does succeed.

So, conditions after the B override are unaffected by said override. They go back to using the recipe's original flags (H).

dg99
  • 2,642
  • 1
    Indeed, think of it as if $H was a shell variable which contains the message's headers, and $B its body, and $HB (as well as $BH) their concatenation. – tripleee Oct 18 '17 at 19:26