[alt.sources] "...subjects": better "="

Dan_Jacobson@ATT.COM (07/09/90)

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# 
# Wrapped by danj1 on Sun Jul  8 21:32:09 CDT 1990
# Contents:  ...subjects
 
echo x - ...subjects
sed 's/^@//' > "...subjects" <<'@//E*O*F ...subjects//'
: Dan_Jacobson@ATT.COM 1990-7-8
# A poorperson's somewhat better "=" (list subjects) macro for the rn
# newsreader

# A semi-stupid UNIX netnews subject gatherer for inside rn, because
# rn's "=" isn't good enough.  Anybody can install this in their own
# $HOME/bin, etc. Gives the count, in descending order [so hottest
# topics are at top], of each subject in a newsgroup.  This program
# takes a few seconds to run. It also doesn't look in your .newsrc
# file, so it just lists all subjects, read and unread. Sample output
# [while in newsgroup soc.singles]:

#   32 is monogamy passe?
#   16 bathroom needs (was: meeting women)
#   15 isis position paper on homosexuality
#   [etc.]

# [I bet I'm not the first to make this kind of macro/program, and is
# there a new release of rn that does it?]  This executable file is
# called by an rn macro so that it executes in the newsgroup's spool
# directory, which I assume you have access to (e.g., probably not
# accessible if you're running rrn).  Lists all subjects, read and
# unread.  To bind this to ":", put this line in your $HOME/.rnmac
# file (with the ":" being the first character on the line):

#         : %(%m=[nap]?%(%m=n?.)!!...subjects^j)

# and call this file [that you are reading] "...subjects" and put it
# in your UNIX $PATH.  Why the funny name "...subjects"?  So ls(1)
# won't see it often, as it is a specialized command invoked only from
# your macro file.

test -z "$PAGER" && PAGER="eval echo; cat"
#echo: else output looks ugly when called from newsgroup selection level.

W='[ 	]' #one "white space"... there should be a SPACE and a TAB
# here, otherwise this file got mangled and you should restore those
# two characters

sed "
	/^Subject/!d
	: Z
	s/$W[Rr][Ee]:$W/ /g
	s/$W[Rr][Ee]^2:$W/ /g
	s/$W[Rr][Ee]$W/ /g
	t Z
	s/$W$W*$//
	s/$W$W$W*/ /g
	s/Subject: //g
	y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
	" * | sort | uniq -c | sort -nr | $PAGER
@//E*O*F ...subjects//
chmod u=rwx,g=rx,o=rx ...subjects
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
     51    332   1942 ...subjects
!!!
wc  ...subjects | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0