#! /bin/sh

. ${srcdir=.}/t.frame

# t.ignore_spam_header
#
# 	bogofilter should remove all copies of the spam 
#	header line in the incoming message, i.e. 
#	the output file should exactly 1 copy of it.

shn=`./spam_header_name`

cat > "$TMPDIR/input" <<EOF
From somewhere@example.com Fri Nov 22 11:30:23 2002
$shn: blah1
$shn: blah2
      ... folded continuation 1
      ... folded continuation 2
$shn: blah3

Friend,

EOF

# check seekable input
$VAL $BOGOFILTER -p -e -C < "$TMPDIR"/input > "$TMPDIR/output1"
# check non-seekable input
cat "$TMPDIR/input" | $VAL $BOGOFILTER -p -e -C > "$TMPDIR/output2"

count1=`grep $shn "$TMPDIR"/output1 | wc -l`
count2=`grep $shn "$TMPDIR/output2" | wc -l`

if [ $count1 = "1" ] && [ $count2 = "1" ] ; then
    exit 0
else
    echo count1: $count1, count2: $count2
    exit 1
fi
