*BSD News Article 13601


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!usc!wupost!uunet!pipex!sunic!isgate!veda.is!adam
From: adam@veda.is (Adam David)
Newsgroups: comp.os.386bsd.bugs
Subject: sed misbehaving?
Message-ID: <C4nMG9.JDt@veda.is>
Date: 29 Mar 93 14:19:20 GMT
Organization: Veda Systems, Iceland
Lines: 58

I'm running 0.1 + patchkit 0.2.1 and sed seems to be rather confused.
While hacking the cnews mail-news-mail gateway scripts to work in this
part of the net under 386bsd various inconsistencies became apparent.

The 'distribute' script as supplied and used with the -n flag to gateway
mail into a local newsgroup duplicated all the modified mail headers and
all the lines of the mail message except the last one, also several extra
empty lines were being inserted in the output and messing it up.

After major reworking and abandoning all attempts to use sed's -n flag
and 'p' commands, and rewriting the sed script to avoid branching to
labels (keeping things as simple as frustration allows) the script is now
almost working. Here is the section that doesn't work:

.
.
/^[Rr]eceived:/,/^[^ TAB]/{
	/^[Rr]eceived:/d
	/^[ TAB]/d
}
.
.

TAB is the ascii tab character 0x09, in case it's not obvious this section
discards Received: lines (including any continuation lines starting with
SPACE or TAB). There must be plenty of other tidier ways of doing this but
I'm trying to find a way that actually works here without getting too
complicated. Using an input file that has the following form, the last
continuation line still sneaks out into the output:

input
-----

From ...
Received: from ...
	by ...
Message-Id: ...
Received: from ...
   with ...
Received: from ...
 id ...
Date: ...

output
------

Path: ...
Message-ID: ...
 id ...
Date: ...

The line beginning ' id' should have disappeared already, nothing else
in the script affects this line (or anything else to do with 'Received:').
The other changes are done by other parts of the script.
What is wrong with sed?

--
Adam David (adam@veda.is)