procmail
[Top] [All Lists]

Re: when a pipe *should* stop early

1997-09-19 21:24:42
I had asked,

| >I've a filter recipe that is supposed to drop the last part of the body.

| >Now, what happens if a buffer boundary happens to occur during the unused
| >part, and procmail senses a write error?  It hasn't happened yet, but it
| >might.  I don't want to put the `i' flag on the recipe, because then any
| >other write errors, which I would care to know about, would be ignored.

Philip Guenther replied,

| I believe that all the other causes of write errors would also cause
| the sed or intermediate shell to have a non-zero exit code, which the
| 'w' flag should catch.

Philip, thank you; that's logical and reasonable.

| >Should I change the sed instruction from q to !d [or p with the -n option]
| >so that sed will accept the entire text?  (Normally that is a suboptimal way
| >to write sed code.)

| Paranoia will often cost you something.  This is an example.

It's not paranoia; it's caution, perhaps overcaution.  If I were paranoid,
the more expensive alternative wouldn't make me feel safe either.

The actual dropped part is very small.  Its smallness makes (1) the possi-
bility of hitting a buffer boundary in there tiny and (2) the expense of
sedding to the end very slight.  So why did I even ask?  Just to learn for
the general case, when the dropped portion might be much larger.  The answer
apparently is as Philip said: if the command is designed decently, any other
cause of a write error will also generate a non-zero exit code, so using both
`w' and `i' should do the trick.

<Prev in Thread] Current Thread [Next in Thread>