procmail
[Top] [All Lists]

Removing duplicate header components

1999-02-12 14:42:16
I've recently run into a situation that's got me puzzled.  A list
I subscribe to adds its own Reply-to: header line, but leaves a
poster's RT line there as well, if he adds one.  I'd never seen
a list server that did that, but there it is.  I've been using
the recipe below to reorganize the header components I want to
keep, and duplicate header lines, in the incantation below, get
concatenated, with a newline between, which splits the resulting
header at that point.  No good.

I'd been deleting gratuitous to-list RT lines with:

:0 fwh
* ^Reply-to: <list-posting-addr(_at_)listaddr(_dot_)com>
| formail -I Reply-To:

but that deletes ALL RT lines, and sometimes an author may actually
have an interesting RT line, distinct from his From: line, and I'd
like to preserve it.

Anyone know of a good delete-just-the-first-header-line recipe?

FWIW, here's the header reorganizer:

#Put header lines into predictable order:
#
FROM=`formail -zxFrom:`
MID=`formail -zxMessage-ID:`
DATE=`formail -zxDate:`
CC=`formail -zxCc:`
TT=`formail -zxTo:`
RT=`formail -zxReply-to:`
SUBJ=`formail -zxSubject:`
XM=`formail -zxX-Mailer:`
CT=`formail -czxContent-type:`
:0 fwh
| formail \
        -I "From: $FROM" \
        -I "Reply-to: $RT" \
        -I "X-Mailer: $XM" \
        -I "Content-Type: $CT" \
        -I "Message-Id: $MID" \
        -I "Date: $DATE" \
        -I "To: $TT" \
        -I "Cc: $CC" \
        -I "Subject: $SUBJ" \
| formail -z

Thanks in advance for any ideas.

Jim

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