[net.sources] Interface to /bin/mail for readnews "r" command

ka (12/30/82)

# Program to mail replies to netnews articles using USG mail program.
#
# It invokes the editor to allow you to enter the mail, and then pipes the
# resulting file into /bin/mail.  The editor is started off with a file
# containing "To:" and "Subject:" lines.  If you modify the "To:" line,
# the new destination will be used, so that you can use a more efficient
# path if desired.  To abort the mail, simply exit the editor without writ-
# ing the file.
#
# To use, include a line in your .profile
# 	MAILER="mailer '%s'" export MAILER
# repacing "mailer" with the full pathname of this file.
#
# BUGS:  This fails if the title of the article contained an apostrophy.
#
t=/tmp/mailr$$a
trap "rm -f $t /tmp/mailr$$b" 0
trap : 2 3
title="$1"
case "$title" in
Re:*)	;;
*)	title="Re: $title"
	;;
esac
author="$2"
/bin/echo "To: $author" >$t
/bin/echo "Subject: $title\n" >>$t
/bin/cp $t /tmp/mailr$$b
${EDITOR-ed} $t
if /bin/cmp -s $t /tmp/mailr$$b
then	/bin/echo mail not sent
	exit
fi
to=`line <$t`
to=`expr "$to" : 'To: \(.*\)'`
if test "$to" = ""
then	to="$author"
fi
/bin/mail $to <$t