Now, where did I leave off? Harry had this recipe,
P> ##Remove stuff added by archive server
P> ##Replace unix message format ('^From ' and '^Return-Path: ') lines
P> :0fhbwc
P> * Subject: archive retrieval: latest/[0-9]+
P> | sed -e '1,/BEGIN------------cut here-------------/d' \
P> -e '/END--------------cut here-------------/,$d' \
P> |awk 'BEGIN {"date"|getline;print "From
apollo-list-request(_at_)redhat(_dot_)com", $0 "\nReturn-Path:
<apollo-list-request(_at_)redhat(_dot_)com"};{print}'
and we'd gotten as far as this:
##Remove stuff added by archive server
##Replace unix message format ('^From ' and '^Return-Path: ') lines
:0fwi
* Subject: archive retrieval: latest/[0-9]+
| sed -ne '1,/BEGIN------------cut here-------------/d' \
-e '/END--------------cut here-------------/q' -ep \
|awk 'BEGIN {"date"|getline;print "From
apollo-list-request(_at_)redhat(_dot_)com", $0 "\nReturn-Path:
<apollo-list-request(_at_)redhat(_dot_)com"};{print}'
OK, the goal here is to reduce the body to what is between the "cut here"
lines and to reduce the head to From_ and Return-Path:. The trick to writing
the From_ line is to get the date into proper format. We can do that this
way:
##Remove stuff added by archive server
:0fbwi
* Subject: archive retrieval: latest/[0-9]+
| sed -ne '1,/BEGIN------------cut here-------------/d' \
-e '/END--------------cut here-------------/q' -ep
##Replace unix message format ('^From ' and '^Return-Path: ') lines
:0afhwi
| echo "Return-Path: <apollo-list-request(_at_)redhat(_dot_)com>" | formail
because formail without the -f option will generate a From_ line. I used the
`a' flag rather than `A' because if the sed command fails, I'm guessing Harry
might want to be able to see the full original headers.
If the Return-Path: header is not really necessary and Harry can use the
-f option of procmail, this might be better:
##Remove stuff added by archive server, same way as above
:0fbwi
* Subject: archive retrieval: latest/[0-9]+
| sed -ne '1,/BEGIN------------cut here-------------/d' \
-e '/END--------------cut here-------------/q' -ep
##Replace From_ line a different way:
:0afhwi
| procmail -f apollo-list-request(_at_)redhat(_dot_)com DEFAULT="|" /dev/null
</dev/null
Finally, there's the do-it-all-in-sed-just-to-be-silly-but-claim-the-reason-
is-saving-processes-yeah-right method:
savemetas=$SHELLMETAS # save value of SHELLMETAS
SHELLMETAS # unset SHELLMETAS, procmail doesn't need a shell for this
:0fwi
* Subject: archive retrieval: latest/[0-9]+
| sed -ne '1,s/^From *[^ ][^ ]*/From
apollo-list-request(_at_)redhat(_dot_)com/p' \
-e "2,/BEGIN------------cut here-------------/c\\
Return-Path: <apollo-list-request(_at_)redhat(_dot_)com>\\
\\
" -e '/END--------------cut here-------------/q' -ep
SHELLMETAS=$savemetas # restore value of SHELLMETAS
Most versions of sed do not need the extra line with just two backslashes;
try it with the line first, and if it causes two blank lines instead of just
one, take it out. Either way, this will preserve the timestamp of the
original delivery and not update it.