]> git.ipfire.org Git - thirdparty/bash.git/blame - support/bashbug.sh
Imported from ../bash-2.02.tar.gz.
[thirdparty/bash.git] / support / bashbug.sh
CommitLineData
726f6388
JA
1#!/bin/sh -
2#
ccc6cda3
JA
3# 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.
cce855bc 7# Other versions send mail to bug-bash@gnu.org.
726f6388
JA
8#
9# configuration section:
10# these variables are filled in by the make target in cpp-Makefile
11#
ccc6cda3
JA
12MACHINE="!MACHINE!"
13OS="!OS!"
14CC="!CC!"
15CFLAGS="!CFLAGS!"
16RELEASE="!RELEASE!"
17PATCHLEVEL="!PATCHLEVEL!"
18RELSTATUS="!RELSTATUS!"
19MACHTYPE="!MACHTYPE!"
20
21PATH=/bin:/usr/bin:/usr/local/bin:$PATH
726f6388
JA
22export PATH
23
d166f048
JA
24TEMP=/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"
726f6388 34
ccc6cda3
JA
35case "$RELSTATUS" in
36alpha*|beta*) BUGBASH=chet@po.cwru.edu ;;
cce855bc 37*) BUGBASH=bug-bash@gnu.org ;;
ccc6cda3
JA
38esac
39
d166f048
JA
40case "$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}"
726f6388
JA
51
52: ${EDITOR=emacs}
53
ccc6cda3
JA
54: ${USER=${LOGNAME-`whoami`}}
55
726f6388
JA
56trap '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
cce855bc
JA
72# this is raceable
73rm -f $TEMP
74
726f6388
JA
75cat > $TEMP <<EOF
76From: ${USER}
77To: ${BUGADDR}
78Subject: [50 character or so descriptive subject here (for reference)]
79
80Configuration Information [Automatically generated, do not change]:
81Machine: $MACHINE
82OS: $OS
83Compiler: $CC
84Compilation CFLAGS: $CFLAGS
85uname output: $UN
ccc6cda3 86Machine Type: $MACHTYPE
726f6388
JA
87
88Bash Version: $RELEASE
89Patch Level: $PATCHLEVEL
ccc6cda3 90Release Status: $RELSTATUS
726f6388
JA
91
92Description:
ccc6cda3 93 [Detailed description of the problem, suggestion, or complaint.]
726f6388
JA
94
95Repeat-By:
ccc6cda3
JA
96 [Describe the sequence of events that causes the problem
97 to occur.]
726f6388
JA
98
99Fix:
ccc6cda3
JA
100 [Description of how to fix the problem. If you don't know a
101 fix for the problem, don't include this section.]
726f6388
JA
102EOF
103
cce855bc
JA
104# this is still raceable
105rm -f $TEMP.x
726f6388 106cp $TEMP $TEMP.x
cce855bc 107chmod u+w $TEMP
726f6388 108
ccc6cda3
JA
109trap '' 2 # ignore interrupts while in editor
110
111until $EDITOR $TEMP; do
112 echo "$0: editor \`$EDITOR' exited with nonzero status."
113 echo "$0: Perhaps it was interrupted."
d166f048
JA
114 echo "$0: Type \`y' to give up, and lose your bug report;"
115 echo "$0: type \`n' to re-enter the editor."
ccc6cda3
JA
116 echo $n "$0: Do you want to give up? $c"
117
118 read ans
119 case "$ans" in
d166f048 120 [Yy]*) exit 1 ;;
ccc6cda3
JA
121 esac
122done
123
124trap 'rm -f $TEMP $TEMP.x; exit 1' 2 # restore trap on SIGINT
125
126if cmp -s $TEMP $TEMP.x
726f6388 127then
ccc6cda3
JA
128 echo "File not changed, no bug report submitted."
129 exit
726f6388
JA
130fi
131
d166f048
JA
132echo $n "Send bug report? [y/n] $c"
133read ans
134case "$ans" in
135[Nn]*) exit 0 ;;
136esac
137
ccc6cda3
JA
138${RMAIL} $BUGADDR < $TEMP || {
139 cat $TEMP >> $HOME/dead.bashbug
140 echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
141}
142
726f6388 143exit 0