#!/bin/sh -
#
# bashbug - create a bug report and mail it to bug-bash@prep.ai.mit.edu
#
# configuration section:
#	these variables are filled in by the make target in cpp-Makefile
#
MACHINE="amiga"
OS="NetBSD"
CC="gcc "
CFLAGS=" -O3 -static -DHAVE_SETLINEBUF -DHAVE_VFPRINTF -DHAVE_UNISTD_H -DHAVE_STDLIB_H -DHAVE_LIMITS_H        -DHAVE_GETGROUPS -DHAVE_RESOURCE -DHAVE_SYS_PARAM -DVOID_SIGHANDLER -DHAVE_BCOPY -DHAVE_GETDTABLESIZE -DHAVE_GETHOSTNAME -DHAVE_RESOURCE -DHAVE_SOCKETS -DHAVE_UID_T -DNEED_SYS_PARAM -DOPENDIR_NOT_ROBUST -DHAVE_WAIT_H        -DHAVE_GETWD -DHAVE_DUP2 -DHAVE_STRERROR  -DHAVE_DIRENT_H -DHAVE_STRING_H        -DHAVE_VARARGS_H -DHAVE_STRCHR -DHAVE_STRCASECMP -DHAVE_DEV_FD -DRLIMTYPE=quad_t       -Damiga -DNetBSD -DSHELL -DHAVE_ALLOCA  	  "
RELEASE="1.14"
PATCHLEVEL="1"

PATH=/bin:/usr/bin:usr/local/bin:$PATH
export PATH

TEMP=/tmp/bashbug.$$

BUGADDR=${1:-bug-bash@prep.ai.mit.edu}

: ${EDITOR=emacs}

trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
trap 'rm -f $TEMP $TEMP.x' 0

UN=
if (uname) >/dev/null 2>&1; then
	UN=`uname -a`
fi

cat > $TEMP <<EOF
To: ${BUGADDR}
Subject: [50 character or so descriptive subject here (for reference)]

Configuration Information [Automatically generated, do not change]:
Machine: $MACHINE
OS: $OS
Compiler: $CC
Compilation CFLAGS: $CFLAGS
uname output: $UN

Bash Version: $RELEASE
Patch Level: $PATCHLEVEL

Description:
        [Detailed description of the problem, suggestion, or complaint.]

Repeat-By:
        [Describe the sequence of events that causes the problem
        to occur.]

Fix:
        [Description of how to fix the problem.  If you don't know a
        fix for the problem, don't include this section.]
EOF

chmod u+w $TEMP
cp $TEMP $TEMP.x

if $EDITOR $TEMP
then
	if cmp -s $TEMP $TEMP.x
	then
		echo "File not changed, no bug report submitted."
		exit
	fi

	rmail $BUGADDR < $TEMP || cat $TEMP >> $HOME/dead.bashbug
fi

exit 0
