#!/bin/sh -eu # digest-checker -- See if a digest has any bad message separators etc. # Copyright : http://www.fsf.org/copyleft/gpl.html # Author : Dan Jacobson -- http://jidanni.org/comp/mail/ # Created On : Mon May 31 01:28:34 2004 # Last Modified By: # Last Modified On: Sat Jan 15 14:44:53 2011 # Update Count : 83 # Pipe a potential e.g. RISKS digest through this program to find bad # separators etc. before the the issue hits the newsstands. Of recent # RISKS issues at the time of this writing, 23.34, 23.39 had separator # discrepancies. The RISKS moderator enjoyed this program. # A bad separator could result in readers missing an article, # especially if it is tacked at the back of a boring article, as it # often won't appear in their reader program's table of contents. t=/tmp/risks.$$ exitval=0 cat > $t w=-mwarnings=FATAL,all echo -n "`basename $0`: checking: " perl $w -nwe 's/^Subject: // && print && exit' $t echo Probable separators: perl $w -nwe 'next if /^-{70}$/;#ought to check this too though print if /-{20}/' $t|sort|tee $t.1|uniq -c|cat -e echo tr \\n @ <$t| perl $w -plwe 's/\@\@-{30}\@\@/\n_OK_SEPARATOR_\n/g'| perl $w -nwe 'print if/^_OK_SEPARATOR_$/'>$t.2 set `wc -l $t.[12]` probable=$1 ok=$3 echo $probable probable, and $ok OK separators. # Also check for rarely intentional shameful trailing whitespace, # visible to me thanks to emacs' show-trailing-whitespace, and now # letting you know too. # Indeed, cleaning up trailing whitespace will often also cure one's invalid # separators, if any. #whitespace_lines=`perl $w -nlwe 'print $. if /\s$/' $t` if test $probable -ne $ok then echo "********** $probable PROBABLE != $ok OK !!!" echo OK separators are '\n\n-{30}\n\n', no more, no less. exitval=11 fi set +e perl $w -nlwe ' BEGIN { $w = $l = ""; $maxchars = 80; $e = 0 }; $w .= " $." if /\s$/; $l .= " $." if ( length > $maxchars ); END { if ( length $w ) { print "\nTrailing whitespace on lines:$w"; $e++ } if ( length $l ) { print "\nMore than $maxchars chars on lines:$l"; $e++; } #Checking long lines too. #Of course we often thus produce more long lines :-) exit $e; } ' $t exitval=`expr $exitval + $?` set -e rm $t $t.1 $t.2 exit $exitval # I didn't check if there were other programs that did the same. # Could be extended to check for other bad things. :||<