[8676] in Athena Bugs
Re: MH path requirements for sendbug
daemon@ATHENA.MIT.EDU (Jim Haynes)
Tue Nov 26 13:17:49 1991
From: haynes@cats.UCSC.EDU (Jim Haynes)
Date: Tue, 26 Nov 91 10:17:05 -0800
To: bugs@Athena.MIT.EDU
Here's a sendbug that doesn't use MH (it was hacked from Pnews instead)
#!/bin/sh
# $Id: sendbug.sh,v 2.0 1991/11/10 05:56:43 haynes Exp $
# make sure stuff this script needs is up front
bugs_address=bugs@CATS.UCSC.EDU
sendmail="/usr/lib/sendmail -t -oi"
report_file=/tmp/bug$$.text
version_file=/etc/athena/version
pager="${PAGER-/usr/ucb/more}"
if [ ! -r $version_file ]; then
version="unknown version (no $version_file found)"
else
awk_cmd='\
{if ($5 == "Update") update++; \
else if ($5 == version) { same++; update=0; } \
else { version=$5; update=0; same=0; } } \
END { printf "%s", version; \
close=0; \
if (update) { printf " (plus partial update"; close=1; }\
else if (same) { \
if (close) printf "; "; \
else printf " ("; \
printf "%d update(s) to same version", same; \
close=1; } \
if (close) printf ")"; \
}'
version=`awk "$awk_cmd" < $version_file`
fi
short_version=`expr "$version (" : '\([^(]*[^( ]\) *(.*'`
machtype=`machtype`
cpu=`machtype -c`
hostname=`hostname`
dpy=`machtype -d`
/usr/ucb/fmt << EOF
Please enter the subject for this bug report. (Generally, this means the
name of the program or locker with which you are having problems.)
EOF
echo -n ' --> '
read subject
cat > $report_file << EOF
To: $bugs_address
Subject: $machtype $short_version: $subject
-------
System name: $hostname
Type and version: $cpu $version
Display type: $dpy
What were you trying to do?
[Please replace this line with your information.]
What's wrong:
[Please replace this line with your information.]
What should have happened:
[Please replace this line with your information.]
Please describe any relevant documentation references:
[Please replace this line with your information.]
EOF
fmt << EOF
Please fill in the specified fields of the bug report form, which will
be displayed momentarily.
Remember to save the file before exiting the editor.
EOF
# not using MH; run the editor, and send, ourselves.
if [ "x$EDITOR" = "x" ]; then
EDITOR=/usr/ucb/vi ; export EDITOR
fi
$EDITOR $report_file
# the rest of this is stolen from Rnmail
state=ask
while true ; do
case $state in
edit)
rescue="sleep 1; cat $report_file >>${HOME-$LOGDIR}/dead.letter ; echo Message appended to ${HOME-$LOGDIR}/dead.letter ; exit"
trap "$rescue" 1
trap : 2
case "${VISUAL-${EDITOR-}}" in
'')
tmp=h
;;
*)
tmp=''
;;
esac
while test "$tmp" = h ; do
echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
read tmp
case $tmp in
h)
cat <<'EOH'
Type a return to get the default editor, or type the name of the editor you
prefer. The default editor depends on the VISUAL and EDITOR environment
variables.
EOH
;;
'')
;;
*)
VISUAL=$tmp
export VISUAL
;;
esac
done
${VISUAL-${EDITOR-$defeditor}} $report_file
trap "$rescue" 2
state=ask
;;
ask)
echo ""
echo $n "Send, abort, edit, or list? $c"
read ans
case $ans in
a*)
state=rescue
;;
e*)
set $ans
case $# in
2) VISUAL="$2" ;;
esac
state=edit
;;
l*)
$pager $report_file
state=ask
;;
s*)
state=send
;;
h*)
cat <<'EOH'
Type s to send the message, a to abort and append the message to dead.letter,
e to edit the message again, or l to list the message.
To invoke an alternate editor, type 'e editor'.
EOH
esac
;;
send)
$sendmail $bugs_address < $report_file
case $? in
0)
state=cleanup
;;
*)
state=rescue
;;
esac
;;
rescue)
cat $report_file >> ${HOME-$LOGDIR}/dead.letter
echo "Message appended to ${HOME-$LOGDIR}/dead.letter"
exit
;;
cleanup)
case "${MAILRECORD-none}" in
none)
;;
*) if cat $report_file >> $MAILRECORD; then
echo "Article appended to $MAILRECORD"
else
echo "Cannot append to $MAILRECORD"
fi
;;
esac
exit
;;
esac
done
/bin/rm -f $report_file