🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.misc
Article #5450

from.sed (v1.2)

#5450
From: John Chew
Date: Wed, 20 Dec 1989 22:27
45 lines
2100 bytes
Here's a new version of from.sed, my sed script that does the job
of from(1) better and faster.  It now truncates long subjects,
correctly handles messages without subjects and From lines with %
or @foo: routing.

To use it, save the lines below in a file (say from.sed) and either 
define an alias to invoke sed (sed -f from.sed /usr/spool/mail/john)
or wrap a teeny shell script around it to do the same thing (not
recommended, as the point of the script was to save the sort of
time that would get wasted by the shell).

Yes, I tried writing this in Perl.  I'm not an expert Perl programmer,
but I couldn't get it to run faster than about 70% slower than sed.

If you install this and find that large portions of mail headers
work their way into your output, your sed does not support the
magic '#n' comment.  I haven't found any seds that do, nor any
sed documentation that mentions the comment, so send me mail and
invoke the script with `sed -n' instead of just `sed'.

Bug reports, entertaining flames, shameless flattery welcome.

John
----- begin from.sed -----
#n from.sed v1.2 Copyright (C) 1989 John Chew <poslfit@gpu.UTCS.UToronto.CA>

/^From /!d
s///
s/^[^ ]*[!:]\([^ !:]*\) /\1 /
s/^\([^ @%]*\)[@%][^ ]* /\1 /
s/ /           /
s/^\(..........\)[^ ]* *\(.*\)/\2 \1/
h
: loop
  n
  /^$/!b    hdr
    g;p;d;: hdr
  /^Subject:/!b loop
s/^\(Subject: ...........................................\).*/\1/
H;g;s/\nSubject: */ /p
----- end from.sed -----
-- 
john j. chew, iii   		  phone: +1 416 425 3818     AppleLink: CDA0329
trigraph, inc., toronto, canada   {uunet!utai!utcsri,utgpu,utzoo}!trigraph!john
dept. of math., u. of toronto     poslfit@{utorgpu.bitnet,gpu.utcs.utoronto.ca}
Technical Details
Message-ID: <1989Dec20.222732.5633@trigraph.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!trigraph!john

Show Full Headers
Complete Article Headers
Newsgroups: comp.mail.misc
Path: arc1-ca.pugleaf.net!utzoo!utgpu!trigraph!john
From: john@trigraph.uucp (John Chew)
Subject: from.sed (v1.2)
Message-ID: <1989Dec20.222732.5633@trigraph.uucp>
Sender: "John J. Chew" <john@trigraph.UUCP>
Reply-To: "John J. Chew" <poslfit@gpu.UTCS.UToronto.CA>
Organization: Trigraph Inc., Toronto, Canada
Date: Wed, 20 Dec 89 22:27:32 GMT