At 10:24 AM 5/26/97 +0300, era eriksson wrote:
On Sun, 25 May 1997 23:20:09 -0700 (PDT),
[snip]
If you really want to get rid of the brackets, sed -e 's/[<>]//g'
should do that (but probably not be worth it -- I'd keep the brokets
in the file instead).
If you really insist that you want the contents of the From: field
under all circumstances, you run into a bit of trouble because parsing
that is not trivial under all circumstances. But if you're content
with an approximative method, try running the following on the output
of formail -zxFrom:
sed -e 's/ *([^)]*) *//g' -e 's/.*<\([^>]*\)>.*/\1/g'
Cute. But if you're willing to assume that email addresses have an "@"
in them and are well-behaved, wouldn't this work to set $MATCH with
no external process?:
* ^From:.*[ <]\/[^ <]*(_at_)[^ >]*
(There should be a space and tab in each of the []'s, but this stupid
mailer won't put them in; I'm not on the shell machine at the moment.)
[more snip]
This can and will break with elaborate parenthesized comments in the
From: header -- RFC822 permits quite complicated expressions, although
in practice you rarely see anything other than the following three
variants:
From: address(_at_)host(_dot_)domain(_dot_)com
From: address(_at_)host(_dot_)domain(_dot_)com (I am the Walrus)
From: The Walrus <address(_at_)host(_dot_)domain(_dot_)com>
Your sed script is more "rugged" than my $MATCH; mine won't work on
local users (no "@" in email address, typically) or on some
of the exceptions yours will catch such as
From: "IAm(_at_)KoolDude" <address(_at_)whatever(_dot_)com>
But can't formail do it "right" anyway? Make a copy of the
header, then strip out all reply headerfields except "From:", and
then generate FROM=`formail...` from the remainder (there will then
be nothing left *but* "From:" for formail to "reply" to)?
(Left as an exercise to the reader; not sure if it can be done
in one formail call; I'd probably end up using two :)
Hope this helps,
Me too :)
Cheers,
Stan