]>
git.ipfire.org Git - thirdparty/bash.git/blob - support/bashbug.sh
3 # bashbug - create a bug report and mail it to the bug address
5 # The bug address depends on the release status of the shell. Versions
6 # with status `devel', `alpha', `beta', or `rc' mail bug reports to
7 # chet@po.cwru.edu and, optionally, to bash-testers@po.cwru.edu.
8 # Other versions send mail to bug-bash@gnu.org.
10 # configuration section:
11 # these variables are filled in by the make target in Makefile
18 PATCHLEVEL
="!PATCHLEVEL!"
19 RELSTATUS
="!RELSTATUS!"
22 PATH
=/bin
:/usr
/bin
:/usr
/local
/bin
:$PATH
25 # If the OS supplies a program to make temp files with semi-random names,
31 # if we don't have mktemp or tempfile, we don't want to see error messages
32 # like `mktemp: not found', so temporarily redirect stderr using {...} while
33 # trying to run them. this may fail using old versions of the bourne shell
34 # that run {...} blocks with redirections in subshells; in that case we're
35 # no worse off than previous versions
37 { TEMPFILE1
=`mktemp "$TMPDIR/bbug.XXXXXX" 2>/dev/null` ; } 2>/dev
/null
38 if [ -z "$TEMPFILE1" ]; then
39 { TEMPFILE1
=`tempfile --prefix bbug --mode 600 2>/dev/null`; } 2>/dev
/null
41 if [ -z "$TEMPFILE1" ]; then
42 TEMPFILE1
=$TMPDIR/bbug.$$
45 { TEMPFILE2
=`mktemp "$TMPDIR/bbug.XXXXXX" 2>/dev/null`; } 2>/dev
/null
46 if [ -z "$TEMPFILE2" ]; then
47 { TEMPFILE2
=`tempfile --prefix bbug --mode 600 2>/dev/null`; } 2>/dev
/null
49 if [ -z "$TEMPFILE2" ]; then
50 TEMPFILE2
="$TMPDIR/bbug.$$.x"
54 USAGE
="Usage: $0 [--help] [--version] [bug-report-email-address]"
55 VERSTR
="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
59 while [ $# -gt 0 ]; do
61 --help) shift ; do_help
=y
;;
62 --version) shift ; do_version
=y
;;
64 -*) echo "bashbug: ${1}: invalid option" >&2
71 if [ -n "$do_version" ]; then
76 if [ -n "$do_help" ]; then
81 Bashbug is used to send mail to the Bash maintainers
82 for when Bash doesn't behave like you'd like, or expect.
84 Bashbug will start up your editor (as defined by the shell's
85 EDITOR environment variable) with a preformatted bug report
86 template for you to fill in. The report will be mailed to the
87 bash maintainers by default. See the manual for details.
89 If you invoke bashbug by accident, just quit your editor without
90 saving any changes to the template, and no bug report will be sent.
95 # Figure out how to echo a string without a trailing newline
102 BASHTESTERS
="bash-testers@po.cwru.edu"
105 alpha
*|beta
*|devel
*|rc
*) BUGBASH
=chet@po.cwru.edu
;;
106 *) BUGBASH
=bug-bash@gnu.org
;;
110 alpha
*|beta
*|devel
*|rc
*)
111 echo "$0: This is a testing release. Would you like your bug report"
112 echo "$0: to be sent to the bash-testers mailing list?"
113 echo $n "$0: Send to bash-testers? $c"
116 y
*|Y
*) BUGBASH
="${BUGBASH},${BASHTESTERS}" ;;
120 BUGADDR
="${1-$BUGBASH}"
122 if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
123 if [ -x /usr
/bin
/editor
]; then
125 elif [ -x /usr
/local
/bin
/ce
]; then
127 elif [ -x /usr
/local
/bin
/emacs
]; then
129 elif [ -x /usr
/contrib
/bin
/emacs
]; then
131 elif [ -x /usr
/bin
/emacs
]; then
133 elif [ -x /usr
/bin
/xemacs
]; then
135 elif [ -x /usr
/contrib
/bin
/jove
]; then
137 elif [ -x /usr
/local
/bin
/jove
]; then
139 elif [ -x /usr
/bin
/vi
]; then
142 echo "$0: No default editor found: attempting to use vi" >&2
148 : ${EDITOR=$DEFEDITOR}
150 : ${USER=${LOGNAME-`whoami`}}
152 trap 'rm -f "$TEMPFILE1" "$TEMPFILE2"; exit 1' 1 2 3 13 15
153 trap 'rm -f "$TEMPFILE1" "$TEMPFILE2"' 0
156 if (uname
) >/dev
/null
2>&1; then
160 if [ -f /usr
/lib
/sendmail
] ; then
161 RMAIL
="/usr/lib/sendmail"
163 elif [ -f /usr
/sbin
/sendmail
] ; then
164 RMAIL
="/usr/sbin/sendmail"
171 INITIAL_SUBJECT
='[50 character or so descriptive subject here (for reference)]'
173 # this is raceable unless (hopefully) we used mktemp(1) or tempfile(1)
174 $rm_tmp1 && rm -f "$TEMPFILE1"
176 cat > "$TEMPFILE1" <<EOF
179 Subject: ${INITIAL_SUBJECT}
181 Configuration Information [Automatically generated, do not change]:
185 Compilation CFLAGS: $CFLAGS
187 Machine Type: $MACHTYPE
189 Bash Version: $RELEASE
190 Patch Level: $PATCHLEVEL
191 Release Status: $RELSTATUS
194 [Detailed description of the problem, suggestion, or complaint.]
197 [Describe the sequence of events that causes the problem
201 [Description of how to fix the problem. If you don't know a
202 fix for the problem, don't include this section.]
205 # this is still raceable unless (hopefully) we used mktemp(1) or tempfile(1)
206 $rm_tmp2 && rm -f "$TEMPFILE2"
208 cp "$TEMPFILE1" "$TEMPFILE2"
209 chmod u
+w
"$TEMPFILE1"
211 trap '' 2 # ignore interrupts while in editor
214 while [ $edstat -ne 0 ]; do
218 if [ $edstat -ne 0 ]; then
219 echo "$0: editor \`$EDITOR' exited with nonzero status."
220 echo "$0: Perhaps it was interrupted."
221 echo "$0: Type \`y' to give up, and lose your bug report;"
222 echo "$0: type \`n' to re-enter the editor."
223 echo $n "$0: Do you want to give up? $c"
233 # find the subject from the temp file and see if it's been changed
234 CURR_SUB
=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
237 "${INITIAL_SUBJECT}")
239 echo "$0: You have not changed the subject from the default."
240 echo "$0: Please use a more descriptive subject header."
241 echo "$0: Type \`y' to give up, and lose your bug report;"
242 echo "$0: type \`n' to re-enter the editor."
243 echo $n "$0: Do you want to give up? $c"
250 echo "$0: The editor will be restarted in five seconds."
258 trap 'rm -f "$TEMPFILE1" "$TEMPFILE2"; exit 1' 2 # restore trap on SIGINT
260 if cmp -s "$TEMPFILE1" "$TEMPFILE2"
262 echo "File not changed, no bug report submitted."
266 echo $n "Send bug report? [y/n] $c"
272 ${RMAIL} $SMARGS < "$TEMPFILE1" ||
{
273 cat "$TEMPFILE1" >> $HOME/dead.bashbug
274 echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2