Subject: Re: Empty heading check?

From: [email-masked] (David W. Tamkin)
Date: Sun, 10 Jul 1994 00:55:23 -0500 (CDT)

Peter Stark had asked,

| > What about the Star (*) Do I need that too?

Rodger Anderson answered,

| If I've read the documentation correctly, you need a star in front of
| every regular expression if you don't use the count or if the count is
| zero.

Here is the full story on the asterisk to mark a condition line.  (It
doesn't have to be a regexp condition; the asterisk works the same way
with exit status and text size conditions.)

The asterisk means "this isn't the action line yet, even if procmail
expects it by now; this is a[n additional] condition line."  If procmail
finds an initial asterisk where it expects a condition line, it reads the
rest of the line as a condition; if procmail finds an initial asterisk where
it expects an action line, it interprets the rest of the line as a condition
and looks for the action on the next line (which might also have an asterisk
and be a condition, indicating that the action line is still farther along).

If a recipe has no numeric flag there is a default number of conditions
for it.  That number is 1 if there is no 'a', 'A', 'e', nor 'E' flag or
0 if there is.  [A number on the flag line overrides that.]  Now, the actual
number of conditions can be more than, equal to, or fewer than the default.

MORE:

If you have more conditions than the default number, you can put the count
into the flag line or you can mark the extra conditions with asterisks.  It
doesn't hurt to use asterisks on the expected conditions either.  You could
even put some other number, as long as it is less than (or equal to) the real
count of conditions, into the flags, and then have asterisks on at least
those condition lines that are past the count in the flag line.

EQUAL:

If the default number of conditions is 1 and you have exactly one condition,
the asterisk is unnecessary but harmless.  If the default is 0 and there are
no conditions, there is nowhere to put an asterisk anyway.

FEWER:

If the default is 1 but there are no conditions, you *must* use the 0 flag
or procmail will read the action line as a condition.  If the default is 0,
there can't possibly be fewer than zero conditions.

But there is one way that will work with all recipes: always put a 0 in the
flag line and always put an asterisk in front of every condition.  That way
you'll be sure to have the 0 when it's required and the asterisks will take
care of overriding the 0 when it is wrong.

| Here is an example of one of my recipes:
| 
| :0 w:procmail/lock
| * ^TOprocmail
| |rcvstore +procmail

That works.  The default number of expected conditions would be 1, but the
0 flag tells procmail to expect none; then the asterisk tells procmail that
it's getting one anyway.

| If you were to leave out the star, you would have to include the count
| of RE lines, like so:                        ^^^^^^^
| 
| :1 w:procmail/lock
| ^TOprocmail
| |rcvstore +procmail

Not exactly.  That recipe will work, but you don't *have* to use the 1 there;
the default number of condition lines is one.  The 1 doesn't hurt; a 2 would
be trouble.  A 0 could be compensated for with an asterisk on the condition
line, as in Rodger's first example.

| I've gotten the impression the that count method is deprecated.

Here are some reasons for preferring asterisks to a numeric flag:

1. It's easier to develop a habit of always using the 0, always using
   asterisks, and letting procmail do the counting than to remember to
   count conditions on every recipe.

2. In the rare case where there are more condition lines than the eye can
   count at a glance, it's possible for the user to count wrong.  Err on
   the low side without using asterisks, or err on the high side even with
   asterisks, and you have a problem.

3. It's easy to forget to change the numeric flag when you add or remove
   conditions on a recipe.  A too-small number can be overridden with
   asterisks, but if you use asterisks anyway you might as well not count
   conditions the first time you write a recipe and just use the 0; a too-
   large number must be corrected, but 0 is never too large.

David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
[email-masked]   MCI Mail: 426-1818   +1 312 714 5610