case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting newsgroups (with variable substitutions)"
$spitshell >newsgroups <<!GROK!THIS!
$startsh
# $Header: newsgroups.SH,v 4.3.2.7 90/04/23 19:30:41 sob Exp $
# 
# $Log:	newsgroups.SH,v $
# Revision 4.3.2.7  90/04/23  19:30:41  sob
# Extra space removed to make second part of newsgroups work.
# Sigh.
# 
# Revision 4.3.2.6  90/04/06  20:35:37  sob
# Added fixes for SCO Xenix sent by ronald@robobar.co.uk.
# 
# Revision 4.3.2.5  90/03/17  17:27:00  sob
# System V sed and BSD sed don't work quite alike. This change uses a
# syntax that is common between them.
# 
# Revision 4.3.2.4  89/11/08  01:13:35  sob
# Finished modifications to make work with RN and RRN
# 
# Revision 4.3.2.3  89/11/07  22:58:04  sob
# Added final changes to allow rn and rrn to be built from same sources.
# 
# Revision 4.3.2.2  89/11/07  22:52:22  sob
# Added prelimiary support to allow both rrn and rn to be built from same
# sources.
# 
# Revision 4.3.2.1  89/11/06  01:04:39  sob
# Added RRN support from NNTP 1.5
# 
# Revision 4.3  85/05/01  11:43:27  lwall
# Baseline for release with 4.3bsd.
# 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)

: syntax: newsgroups [pattern] [pipeflag]

: System Dependencies

: You might want to change pager to a "make column" program if you have one.
: On the other hand, if your kernel does paging, cat would probably do.
pager="${pager-/usr/ucb/more}"
#NORMALactive="${active-/usr/lib/news/active}"

#NORMALcase \$active in
#NORMAL~*) active=\`$filexp \$active\` ;;
#NORMALesac

#NNTPactive="/tmp/active.\$\$"

: End of system dependencies, hopefully

#NNTP$rnlib/getactive \$active

if $test \$# -ge 2 ; then
    pager=$cat
else
    $echo "Completely unsubscribed newsgroups:"
fi

dotdir=\${DOTDIR-\${HOME-\$LOGDIR}}

: Throwing .newsrc into the pot twice is a lovely hack to prevent
: bogus newsgroups from showing up as unsubscribed.

$cat \$dotdir/.newsrc \$dotdir/.newsrc \$active | \\
$sed -n	-e '/^options/d' \\
	-e '/^[	 ]/d' \\
	-e '/^control/d' \\
	-e '/^to\./d' \\
	-e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
	-e "/.*\$1/p" | \\
$sort | $uniq -u | \$pager
if $test \$# -ge 2 ; then
    exit
fi
$echo $n "[Type return to continue] $c"
read tmp
$echo ""
$echo "Unsubscribed but mentioned in .newsrc:"
$sed -n < \$dotdir/.newsrc \\
	-e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
$sort | \$pager
!GROK!THIS!
case "$isrrn" in
define)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
*) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
esac
mv newsgroups.new newsgroups
$eunicefix newsgroups
chmod 755 newsgroups
