procmail
[Top] [All Lists]

Re: Received: headers after From:

1997-11-08 11:50:45
Stan Ryckman saw my simplified sed solution to the Received:-after-From:
problem (who originally asked that anyway?  I can't remember) and wrote,

| How about a conceptually simpler (to me, anyway) awk solution which just
| relies on three states in effect after we have dealt with each line:
|       s==0    haven't yet seen From
|       s==1    have seen From, want to keep next line if continued
|       s==2    have seen From, want to discard next line if continued

Ed Sabol's first recursive INCLUDERC had a similar statekeeping variable.

| Then:
|   :0fwh
|   * ^From:(.*$)+Received:
|   | gawk 's==0 && !/^[Ff][Rr][Oo][Mm]:/ {print;next}\
|   s==2 && /^[         ]/ || /^[Re][Ee][Cc][Ee][Ii][Vv][Ee][Dd]:/ {s=2;next}\
|   {s=1;print}'

Not grokking awk, much less gawk or nawk, I'll take Stan's word for it, but
I'd stick with sed because it is a smaller binary and it can still do the
job (no arithmetic calculations are needed here, for example); however, my
second sed method beats the pants off the first one I came up with.

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