[net.sources] Fix for postnews "Distribution" problem

riddle@ut-sally.UUCP (Prentiss Riddle) (12/10/83)

I discovered in a mildly embarassing incident on net.games last week that
the normal version of postnews was ignoring the "distribution" spec when
the user invoked it with a filename as an argument.  Here is a new version
of postnews containing my fix for the bug.  (It's really remarkable that
no one has cleared this one up long ago -- the difference is trivial.)

Thanks to Guy Riddle for pointing out the exact nature of the problem.

----------------------------< cut here >----------------------------------
: '@(#)postnews.v7	2.8	4/23/83'
:
: 'modified 12/8/83 by Prentiss Riddle (riddle@ut-sally.UUCP) not to '
: '    ignore a Distribution specification when invoked with a       '
: '    filename argument.                                            '
:
if test $# -gt 1 ; then
	/bin/echo "$0: Too many args"
	exit 1
fi
if test $# -eq 1 -a ! -r "$1" ; then
	/bin/echo "$0: Can't read $1"
	exit 1
fi
/bin/echo -n "Subject: "
read title
/bin/echo -n "Newsgroups (general): "
read ng
if test x$ng = x ; then
	ng=general
fi
/bin/echo -n "Distribution ($ng): "
read dist
if test x$dist = x; then
	dist=$ng
fi
t=/tmp/pn$$
trap "sleep 1; cp $t $HOME/dead.article ; echo saved in $HOME/dead.article ; rm -f $t; exit" 1
trap "" 2
/bin/echo "Subject: $title" > $t
/bin/echo "Newsgroups: $ng" >> $t
if test $dist != $ng; then
	/bin/echo "Distribution: $dist" >> $t
fi
/bin/echo "" >> $t
case $# in
0)
	${EDITOR-vi} $t
	cd /tmp
	if inews -h <$t
	then
		:
	else
		if cat $t >>$HOME/dead.article
		then
			/bin/echo Article saved in $HOME/dead.article
		fi
	fi
	;;
1)
	cat $1 >>$t
	cd /tmp
	inews -h < $t
	;;
esac
sleep 1
rm -f $t
----------------------------< cut here >----------------------------------
Prentiss Riddle
{ihnp4,seismo,ctvax}!ut-sally!riddle