era eriksson wrote:
On Mon, 14 Oct 1996 08:16:22 -0400 (EDT), Rick Troxel
<rick(_at_)helix(_dot_)nih(_dot_)gov> wrote:
> Is there a recipe for detecting messages in which the body is empty?
> The following recipe doesn't work, because (according to the verbose
> log) the "< 2" condition doesn't match.
As far as I can tell, the > and < tests compare the size of the
+whole+ message, including headers. I'd like to see a means to measure
the size of the body directly, too. Meanwhile, I believe you can use
scoring to count the number of lines in the body. See the
procmailsc(5) manual page; I should hope it can explain better than I
can ;-)
The following (only sloppily tested) should test for an empty body:
ISEMPTY=|gawk '/^$/{x=1}\
x && NF>0 {print "NO"; x=2; exit}\
END{ if(x<2) print "YES"}'
(I used gawk because some older awks will choke on "x && NF>0"
but you can use "if"'s to get around that if needed.)
Something like the following (not at all tested) should count words
in the body if that's what is wanted:
BODYWORDS=|gawk '/^$/{x=1}\
x {bodywords += NF}\
END{ print 0+bodywords}'
(easily changed to whatever you want for "size"; if characters,
add up 1+length($0) instead of NF, for example, the 1 being for
the newline with each $0.)
May not be the best way, but it should work. Hope that helps.
Cheers,
Stan Ryckman (stanr(_at_)tiac(_dot_)net)