#! /bin/sh

# $Id: tircbug,v 1.4 1998/02/14 00:20:53 token Exp $

# TIRC bug report form.  This allows you to fill out a proper bug report
# which is then mailed to the TIRC mailing list with the appropriate
# version etc.

mailto="tirc@mayn.de"

echo
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "This utility is for interactively reporting bugs in the TIRC irc client"
echo "to the appropriate place (the TIRC mailing list).  It will generate a"
echo "template which you are then asked to fill out."
echo
echo "Continue reporting a bug, anomaly or proposal?"
echo "[yes or no]"

read answ

case "$answ" in
y*)	doreport=yes;;
*)	doreport=no;;
esac

if test "$doreport" != yes; then
	echo "Ok."
	exit
fi

echo
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "Use which program for sending the mail?"
echo "This should be a command line mailer agent, like mailx, Mail or elm,"
echo "that reads the text from stdin and can be given a subject with the"
echo "-s option.  Please note that on some systems /bin/mail (binmail) does"
echo "not support -s (and is not rfc-compliant), you should use mailx on these"
echo "systems."
echo "Please enter the mail program name now, or type enter for mailx:"
read mailer

if test "$mailer" = ""; then
	mailer=mailx
fi

tirc_version=`tirc -v || ./tirc -v`

if test "$tirc_version" = ""; then
	echo "Whoops.  Couldn't run TIRC to query the version."
	echo "This is probably because you were not able to compile TIRC?"
	echo "Please enter the compile target system type (operating system"
	echo "name and version) and the TIRC version now."
	echo 'Something like for example "tirc 0.53-alpha, target DEC UNIX V4.0B" would be'
	echo "appropriate."
	read tirc_version
fi

bugfile=/tmp/tircbug.$$

if test "$USER" == ""; then
	USER="$LOGNAME"
fi

echo 'tircbug $Revision: 1.4 $ report' > $bugfile
echo "Submitted by $USER on `hostname` at `date`" >> $bugfile
echo >> $bugfile
echo ";;; TIRC release and target system name/version.  Change if it is wrong." >> $bugfile
echo "Version: $tirc_version" >> $bugfile
cat >> $bugfile << EOF

;;; Hello, thanks for filing a problem report with the TIRC client.
;;; [This may look like GNATS but it really isn't.]
;;;
;;; This is the problem report form which faciliates the reporting of bugs,
;;; annoyances, and future proposals to the TIRC development.
;;;
;;; How to fill out this form:
;;;
;;; Type the appropriate text following the keywords (a keyword for example
;;; is "Category:").
;;;
;;; The "Synopsis" text should be a short 1-liner since it will also be
;;; used as the mail subject.
;;; You don't have to remove anything in this form.  Superfluous text (like
;;; these comments) will get stripped automatically.  You will also be asked
;;; if you really want to send the report afterwards, so don't panic.
;;;
;;; Now, let's begin.

;;; Synopsis: enter a short 1-line summary of the problem on the same line
;;; as the "Synopsis" keyword.
Synopsis: [specify subject here]

;;; Please choose from the following categories:
;;;	
;;;     tirc:	      the report addresses the TIRC core program
;;;	configure:    the report addresses the autoconf configure script
;;;	bundled:      the report addresses any bundled modules (from the
;;;		      dynamically loadable modules tree), and auxiliary
;;;		      programs, such as tircbug
;;;	doc:	      the report addresses the TIRC documentation
;;; 	retrieval:    the report is addressing the retrieval of TIRC from
;;;		      the ftp server, or as a binary package, or whatever
Category:

;;; This somewhat prioritizes the problem report.
;;; Please choose from:
;;;
;;;	critical:     the problem is critical for usage, no workaround is
;;;		      known
;;;	serious:      the problem really affects usage, but a workaround is
;;;		      possible (please specify below)
;;;	medium:	      the problem is rather annoying and should be fixed soon
;;;		      but doesn't really affect functionality
;;;	non-critical: a slight anomaly, or proposal for future change or
;;;		      enhancement
Severity:

;;; Please give a short but detailed description of the issue.
;;; (in case of a problem, when does it happen?  Is it reproducable?
;;;  did you do a post-mortem analysis of the core dump?)
;;;
;;; To analyze a corefile, type "dbx tirc corefilename" or
;;; "gdb tirc corefilename".  This is only useful when you compiled the
;;; client with --enable-debug.  When the debugger has started, type "where"
;;; or "backtrace" and include the output (if it gets too long, truncate)
;;; here.
Description:


;;; If you know of any workaround that (temporarily) eliminates the problem,
;;; or a fix, please state it here, or type "none".
Workaround:


;;; Please also answer the following questions.
Do you think the problem is specific to your system/architecture?

Do you think the bug also affects other programs that are similar to TIRC
(like ircII, for example)?


;;; Done with it.  Thanks again for taking the time to fill in this
;;; report.
EOF

echo
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "I will now start your favourite text editor to fill in the report form."
echo "See you later."
echo
echo [enter]
read $answ

if test "$EDITOR" != ""; then
	$EDITOR $bugfile
else
	vi $bugfile
fi

echo
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "Do you want to file the bug report to $mailto?"
echo
echo "[yes or no]"

read answ

case "$answ" in
y*)	fileit=yes;;
*)	fileit=no;;
esac

if test "$fileit" = yes; then
	synopsis=`grep "^Synopsis:" $bugfile | sed 's/Synopsis:/tircbug:/'` 
	sed '/^;;;/d' < $bugfile | $mailer -s "$synopsis" $mailto
	echo
	echo "Mail sent.  Done with the problem report."
	echo
fi

rm -f $bugfile

