procmail
[Top] [All Lists]

Re: =| and newlines

2001-08-29 00:46:53
From: Don Hammond <procmail1(_at_)tradersdata(_dot_)com>
Date: Tue, 28 Aug 2001 11:20:54 -0400 (EDT)

The premise is incorrect. The =| construct is not embedding newlines.

From: Dallman Ross <dman(_at_)nomotek(_dot_)com>
Date: Tue, 28 Aug 2001 10:35:35 -0400 (EDT)

I don't arrive at the same conclusion with my empirical test
using 3.15.  What caused you to so conclude?

Yes, I later discovered that I was incorrect.  The problem turned out to have
nothing to do with newlines, but rather spaces.

The problem was this:

NUMWORDS=`wc -w`

:0wc
SCORE1=|ifile -h -w -q|grep ^nonspam|awk '{print $2}'|sed -e 
's,^$,'$NUMWORDS',;s,^,'$SCORE'-(,;s,$,)/(2*'$NUMWORDS'),'|bc

The value of NUMWORDS was "    456", i.e. a string with a bunch of spaces at
the beginning.  Previously, I was using C-shell and, for some reason, using
$NUMWORDS got rid of the spaces.  With bash, it gave the spaces to the command
line, so sed got:

sed -e 's,^$,'    456',;s,^,'$SCORE'-(,;s,$,)/(2*'    456'),'

I.e., what I thought would be a single parameter given to sed turned into 3.

I fixed this by adding:

:0w
*NUMWORDS??^^[   ]*\/[0-9]+
{ NUMWORDS=$MATCH }

before the sed gets executed.

Sorry for being so off-base about all this!

-- 
Robert Brown, Programmer/Sys Admin |                http://www.TopicalNet.com
mailto:robertb(_at_)topicalnet(_dot_)com      |                      99.9% 
dolphin-free!
voice: 781-932-8400 x100           |         800 West Cummings Park, Ste 2900
fax: 781-932-2558                  |                    Woburn, MA 01801-6351

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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