blob: e12fdac4ac4af49db9dd2c51f0ce50ecbc0e6f6a [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001#!/bin/sh -
2#
Jari Aaltoccc6cda1996-12-23 17:02:34 +00003# bashbug - create a bug report and mail it to the bug address
4#
5# The bug address depends on the release status of the shell. Versions
6# with status `alpha' or `beta' mail bug reports to chet@po.cwru.edu.
7# Other versions send mail to bug-bash@prep.ai.mit.edu.
Jari Aalto726f6381996-08-26 18:22:31 +00008#
9# configuration section:
10# these variables are filled in by the make target in cpp-Makefile
11#
Jari Aaltoccc6cda1996-12-23 17:02:34 +000012MACHINE="!MACHINE!"
13OS="!OS!"
14CC="!CC!"
15CFLAGS="!CFLAGS!"
16RELEASE="!RELEASE!"
17PATCHLEVEL="!PATCHLEVEL!"
18RELSTATUS="!RELSTATUS!"
19MACHTYPE="!MACHTYPE!"
Jari Aalto726f6381996-08-26 18:22:31 +000020
Jari Aaltoccc6cda1996-12-23 17:02:34 +000021PATH=/bin:/usr/bin:/usr/local/bin:$PATH
Jari Aalto726f6381996-08-26 18:22:31 +000022export PATH
23
Jari Aaltod166f041997-06-05 14:59:13 +000024TEMP=/tmp/bbug.$$
25
26# Figure out how to echo a string without a trailing newline
27N=`echo 'hi there\c'`
28case "$N" in
29*c) n=-n c= ;;
30*) n= c='\c' ;;
31esac
32
33BASHTESTERS="bash-testers@po.cwru.edu"
Jari Aalto726f6381996-08-26 18:22:31 +000034
Jari Aaltoccc6cda1996-12-23 17:02:34 +000035case "$RELSTATUS" in
36alpha*|beta*) BUGBASH=chet@po.cwru.edu ;;
37*) BUGBASH=bug-bash@prep.ai.mit.edu ;;
38esac
39
Jari Aaltod166f041997-06-05 14:59:13 +000040case "$RELSTATUS" in
41alpha*|beta*) echo "$0: This is a testing release. Would you like your bug report"
42 echo "$0: to be sent to the bash-testers mailing list?"
43 echo $n "$0: Send to bash-testers? $c"
44 read ans
45 case "$ans" in
46 y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
47 esac ;;
48esac
49
50BUGADDR="${1-$BUGBASH}"
Jari Aalto726f6381996-08-26 18:22:31 +000051
52: ${EDITOR=emacs}
53
Jari Aaltoccc6cda1996-12-23 17:02:34 +000054: ${USER=${LOGNAME-`whoami`}}
55
Jari Aalto726f6381996-08-26 18:22:31 +000056trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
57trap 'rm -f $TEMP $TEMP.x' 0
58
59UN=
60if (uname) >/dev/null 2>&1; then
61 UN=`uname -a`
62fi
63
64if [ -f /usr/lib/sendmail ] ; then
65 RMAIL="/usr/lib/sendmail"
66elif [ -f /usr/sbin/sendmail ] ; then
67 RMAIL="/usr/sbin/sendmail"
68else
69 RMAIL=rmail
70fi
71
72cat > $TEMP <<EOF
73From: ${USER}
74To: ${BUGADDR}
75Subject: [50 character or so descriptive subject here (for reference)]
76
77Configuration Information [Automatically generated, do not change]:
78Machine: $MACHINE
79OS: $OS
80Compiler: $CC
81Compilation CFLAGS: $CFLAGS
82uname output: $UN
Jari Aaltoccc6cda1996-12-23 17:02:34 +000083Machine Type: $MACHTYPE
Jari Aalto726f6381996-08-26 18:22:31 +000084
85Bash Version: $RELEASE
86Patch Level: $PATCHLEVEL
Jari Aaltoccc6cda1996-12-23 17:02:34 +000087Release Status: $RELSTATUS
Jari Aalto726f6381996-08-26 18:22:31 +000088
89Description:
Jari Aaltoccc6cda1996-12-23 17:02:34 +000090 [Detailed description of the problem, suggestion, or complaint.]
Jari Aalto726f6381996-08-26 18:22:31 +000091
92Repeat-By:
Jari Aaltoccc6cda1996-12-23 17:02:34 +000093 [Describe the sequence of events that causes the problem
94 to occur.]
Jari Aalto726f6381996-08-26 18:22:31 +000095
96Fix:
Jari Aaltoccc6cda1996-12-23 17:02:34 +000097 [Description of how to fix the problem. If you don't know a
98 fix for the problem, don't include this section.]
Jari Aalto726f6381996-08-26 18:22:31 +000099EOF
100
101chmod u+w $TEMP
102cp $TEMP $TEMP.x
103
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000104trap '' 2 # ignore interrupts while in editor
105
106until $EDITOR $TEMP; do
107 echo "$0: editor \`$EDITOR' exited with nonzero status."
108 echo "$0: Perhaps it was interrupted."
Jari Aaltod166f041997-06-05 14:59:13 +0000109 echo "$0: Type \`y' to give up, and lose your bug report;"
110 echo "$0: type \`n' to re-enter the editor."
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000111 echo $n "$0: Do you want to give up? $c"
112
113 read ans
114 case "$ans" in
Jari Aaltod166f041997-06-05 14:59:13 +0000115 [Yy]*) exit 1 ;;
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000116 esac
117done
118
119trap 'rm -f $TEMP $TEMP.x; exit 1' 2 # restore trap on SIGINT
120
121if cmp -s $TEMP $TEMP.x
122then
123 echo "File not changed, no bug report submitted."
124 exit
Jari Aalto726f6381996-08-26 18:22:31 +0000125fi
126
Jari Aaltod166f041997-06-05 14:59:13 +0000127echo $n "Send bug report? [y/n] $c"
128read ans
129case "$ans" in
130[Nn]*) exit 0 ;;
131esac
132
Jari Aaltoccc6cda1996-12-23 17:02:34 +0000133${RMAIL} $BUGADDR < $TEMP || {
134 cat $TEMP >> $HOME/dead.bashbug
135 echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
136}
137
Jari Aalto726f6381996-08-26 18:22:31 +0000138exit 0