procmail
[Top] [All Lists]

Re: $ interpretation and var ?? ? program

1997-01-20 13:06:51
Philip Guenther explained,

| Procmail processes any mix of the leading 'specials', including '!',
| '$', 'var ??', and 'w^x', in the order they appear, so that
| 
| FOO = BAR
| BAR = 5^100
| BAZ = '$QUUX ? cat >/tmp/foo; test -s /tmp/foo'
| QUUX = '$FOO ??'
| 
| :0
| * $ $ \$$FOO $ $BAZ
| /dev/null
| 
| Would result in procmail parsing the condition in the following stages:
| 
|       $ $ \$$FOO $ $BAZ
|                       process leading $
|       $ $BAR $ $QUUX ? cat >/tmp/foo; test -s /tmp/foo
|                       process leading $
|       5^100 $ $FOO ?? ? cat >/tmp/foo; test -s /tmp/foo
|                       Set weight to 5 and exponent to 100
|       $ $FOO ?? ? cat >/tmp/foo; test -s /tmp/foo
|                       process leading $
|       BAR ?? ? cat >/tmp/foo; test -s /tmp/foo
|                       set egrep/pipe source to the variable BAR
|       ? cat >/tmp/foo; test -s /tmp/foo
|                       Ah, the actual test!

Thank you for the detailed example, Philip.

| Well, I can find where it says that backquote expansions get the entire
| message on stdin, but it never says what "? program" conditions have on
| stdin, much less that they get anything at all, as far as I can tell.
| This is a documentation bug if nothing else.  David, do you want to
| send a doc correction to Stephen, or should I?
| 
| Here's a demo:

[Philip then illustrated that a `B' on the flag line makes procmail feed only
 the body to the program in an exit code condition without need to specify
 "B ??" for the condition itself.]

Since you have the evidence, Philip, and you discovered the answer, it's
your privilege to deliver the news.

Curious sidelight: procmail doesn't complain if the program in an exit code
condition doesn't read the message in.  It might be an alternative to the
`i' flag (though I think the `i' is easier to use) or a sneaky way to get
two actions out of one recipe.  If you use it to get two actions out of
one recipe, be sure that a failed exit code won't prevent the other action
line (unless you want it that way): for example,

  :0 flags [:lockfile]
  * conditions
  * .00001^.00001 ? action1
  | action2