1 | #!/bin/sh -
|
---|
2 | #
|
---|
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 `devel', `alpha', `beta', or `rc' mail bug reports to
|
---|
7 | # chet@cwru.edu and, optionally, to bash-testers@cwru.edu.
|
---|
8 | # Other versions send mail to bug-bash@gnu.org.
|
---|
9 | #
|
---|
10 | # Copyright (C) 1996-2004 Free Software Foundation, Inc.
|
---|
11 | #
|
---|
12 | # This program is free software; you can redistribute it and/or modify
|
---|
13 | # it under the terms of the GNU General Public License as published by
|
---|
14 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
15 | # any later version.
|
---|
16 | #
|
---|
17 | # This program is distributed in the hope that it will be useful,
|
---|
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | # GNU General Public License for more details.
|
---|
21 | #
|
---|
22 | # You should have received a copy of the GNU General Public License
|
---|
23 | # along with this program; if not, write to the Free Software
|
---|
24 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
---|
25 |
|
---|
26 | #
|
---|
27 | # configuration section:
|
---|
28 | # these variables are filled in by the make target in Makefile
|
---|
29 | #
|
---|
30 | MACHINE="i686"
|
---|
31 | OS="msys"
|
---|
32 | CC="gcc"
|
---|
33 | CFLAGS=" -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='msys' -DCONF_MACHTYPE='i686-pc-msys' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS -I. -I/c/projetos/msys-bash/bash3/bash-3.1 -I/c/projetos/msys-bash/bash3/bash-3.1/include -I/c/projetos/msys-bash/bash3/bash-3.1/lib -O2 -fno-unit-at-a-time -s -march=i386 -mtune=i686"
|
---|
34 | RELEASE="3.1"
|
---|
35 | PATCHLEVEL="23"
|
---|
36 | RELSTATUS="release"
|
---|
37 | MACHTYPE="i686-pc-msys"
|
---|
38 |
|
---|
39 | PATH=/bin:/usr/bin:/usr/local/bin:$PATH
|
---|
40 | export PATH
|
---|
41 |
|
---|
42 | # Check if TMPDIR is set, default to /tmp
|
---|
43 | : ${TMPDIR:=/tmp}
|
---|
44 |
|
---|
45 | #Securely create a temporary directory for the temporary files
|
---|
46 | TEMPDIR=$TMPDIR/bbug.$$
|
---|
47 | (umask 077 && mkdir $TEMPDIR) || {
|
---|
48 | echo "$0: could not create temporary directory" >&2
|
---|
49 | exit 1
|
---|
50 | }
|
---|
51 |
|
---|
52 | TEMPFILE1=$TEMPDIR/bbug1
|
---|
53 | TEMPFILE2=$TEMPDIR/bbug2
|
---|
54 |
|
---|
55 | USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"
|
---|
56 | VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
|
---|
57 |
|
---|
58 | do_help= do_version=
|
---|
59 |
|
---|
60 | while [ $# -gt 0 ]; do
|
---|
61 | case "$1" in
|
---|
62 | --help) shift ; do_help=y ;;
|
---|
63 | --version) shift ; do_version=y ;;
|
---|
64 | --) shift ; break ;;
|
---|
65 | -*) echo "bashbug: ${1}: invalid option" >&2
|
---|
66 | echo "$USAGE" >& 2
|
---|
67 | exit 2 ;;
|
---|
68 | *) break ;;
|
---|
69 | esac
|
---|
70 | done
|
---|
71 |
|
---|
72 | if [ -n "$do_version" ]; then
|
---|
73 | echo "${VERSTR}"
|
---|
74 | exit 0
|
---|
75 | fi
|
---|
76 |
|
---|
77 | if [ -n "$do_help" ]; then
|
---|
78 | echo "${VERSTR}"
|
---|
79 | echo "${USAGE}"
|
---|
80 | echo
|
---|
81 | cat << HERE_EOF
|
---|
82 | Bashbug is used to send mail to the Bash maintainers
|
---|
83 | for when Bash doesn't behave like you'd like, or expect.
|
---|
84 |
|
---|
85 | Bashbug will start up your editor (as defined by the shell's
|
---|
86 | EDITOR environment variable) with a preformatted bug report
|
---|
87 | template for you to fill in. The report will be mailed to the
|
---|
88 | bash maintainers by default. See the manual for details.
|
---|
89 |
|
---|
90 | If you invoke bashbug by accident, just quit your editor without
|
---|
91 | saving any changes to the template, and no bug report will be sent.
|
---|
92 | HERE_EOF
|
---|
93 | exit 0
|
---|
94 | fi
|
---|
95 |
|
---|
96 | # Figure out how to echo a string without a trailing newline
|
---|
97 | N=`echo 'hi there\c'`
|
---|
98 | case "$N" in
|
---|
99 | *c) n=-n c= ;;
|
---|
100 | *) n= c='\c' ;;
|
---|
101 | esac
|
---|
102 |
|
---|
103 | BASHTESTERS="bash-testers@cwru.edu"
|
---|
104 |
|
---|
105 | case "$RELSTATUS" in
|
---|
106 | alpha*|beta*|devel*|rc*) BUGBASH=chet@cwru.edu ;;
|
---|
107 | *) BUGBASH=bug-bash@gnu.org ;;
|
---|
108 | esac
|
---|
109 |
|
---|
110 | case "$RELSTATUS" in
|
---|
111 | alpha*|beta*|devel*|rc*)
|
---|
112 | echo "$0: This is a testing release. Would you like your bug report"
|
---|
113 | echo "$0: to be sent to the bash-testers mailing list?"
|
---|
114 | echo $n "$0: Send to bash-testers? $c"
|
---|
115 | read ans
|
---|
116 | case "$ans" in
|
---|
117 | y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
|
---|
118 | esac ;;
|
---|
119 | esac
|
---|
120 |
|
---|
121 | BUGADDR="${1-$BUGBASH}"
|
---|
122 |
|
---|
123 | if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
|
---|
124 | if [ -x /usr/bin/editor ]; then
|
---|
125 | DEFEDITOR=editor
|
---|
126 | elif [ -x /usr/local/bin/ce ]; then
|
---|
127 | DEFEDITOR=ce
|
---|
128 | elif [ -x /usr/local/bin/emacs ]; then
|
---|
129 | DEFEDITOR=emacs
|
---|
130 | elif [ -x /usr/contrib/bin/emacs ]; then
|
---|
131 | DEFEDITOR=emacs
|
---|
132 | elif [ -x /usr/bin/emacs ]; then
|
---|
133 | DEFEDITOR=emacs
|
---|
134 | elif [ -x /usr/bin/xemacs ]; then
|
---|
135 | DEFEDITOR=xemacs
|
---|
136 | elif [ -x /usr/contrib/bin/jove ]; then
|
---|
137 | DEFEDITOR=jove
|
---|
138 | elif [ -x /usr/local/bin/jove ]; then
|
---|
139 | DEFEDITOR=jove
|
---|
140 | elif [ -x /usr/bin/vi ]; then
|
---|
141 | DEFEDITOR=vi
|
---|
142 | else
|
---|
143 | echo "$0: No default editor found: attempting to use vi" >&2
|
---|
144 | DEFEDITOR=vi
|
---|
145 | fi
|
---|
146 | fi
|
---|
147 |
|
---|
148 |
|
---|
149 | : ${EDITOR=$DEFEDITOR}
|
---|
150 |
|
---|
151 | : ${USER=${LOGNAME-`whoami`}}
|
---|
152 |
|
---|
153 | trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15
|
---|
154 | trap 'rm -rf "$TEMPDIR"' 0
|
---|
155 |
|
---|
156 | UN=
|
---|
157 | if (uname) >/dev/null 2>&1; then
|
---|
158 | UN=`uname -a`
|
---|
159 | fi
|
---|
160 |
|
---|
161 | if [ -f /usr/lib/sendmail ] ; then
|
---|
162 | RMAIL="/usr/lib/sendmail"
|
---|
163 | SMARGS="-i -t"
|
---|
164 | elif [ -f /usr/sbin/sendmail ] ; then
|
---|
165 | RMAIL="/usr/sbin/sendmail"
|
---|
166 | SMARGS="-i -t"
|
---|
167 | else
|
---|
168 | RMAIL=rmail
|
---|
169 | SMARGS="$BUGADDR"
|
---|
170 | fi
|
---|
171 |
|
---|
172 | INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'
|
---|
173 |
|
---|
174 | cat > "$TEMPFILE1" <<EOF
|
---|
175 | From: ${USER}
|
---|
176 | To: ${BUGADDR}
|
---|
177 | Subject: ${INITIAL_SUBJECT}
|
---|
178 |
|
---|
179 | Configuration Information [Automatically generated, do not change]:
|
---|
180 | Machine: $MACHINE
|
---|
181 | OS: $OS
|
---|
182 | Compiler: $CC
|
---|
183 | Compilation CFLAGS: $CFLAGS
|
---|
184 | uname output: $UN
|
---|
185 | Machine Type: $MACHTYPE
|
---|
186 |
|
---|
187 | Bash Version: $RELEASE
|
---|
188 | Patch Level: $PATCHLEVEL
|
---|
189 | Release Status: $RELSTATUS
|
---|
190 |
|
---|
191 | Description:
|
---|
192 | [Detailed description of the problem, suggestion, or complaint.]
|
---|
193 |
|
---|
194 | Repeat-By:
|
---|
195 | [Describe the sequence of events that causes the problem
|
---|
196 | to occur.]
|
---|
197 |
|
---|
198 | Fix:
|
---|
199 | [Description of how to fix the problem. If you don't know a
|
---|
200 | fix for the problem, don't include this section.]
|
---|
201 | EOF
|
---|
202 |
|
---|
203 | cp "$TEMPFILE1" "$TEMPFILE2"
|
---|
204 | chmod u+w "$TEMPFILE1"
|
---|
205 |
|
---|
206 | trap '' 2 # ignore interrupts while in editor
|
---|
207 |
|
---|
208 | edstat=1
|
---|
209 | while [ $edstat -ne 0 ]; do
|
---|
210 | $EDITOR "$TEMPFILE1"
|
---|
211 | edstat=$?
|
---|
212 |
|
---|
213 | if [ $edstat -ne 0 ]; then
|
---|
214 | echo "$0: editor \`$EDITOR' exited with nonzero status."
|
---|
215 | echo "$0: Perhaps it was interrupted."
|
---|
216 | echo "$0: Type \`y' to give up, and lose your bug report;"
|
---|
217 | echo "$0: type \`n' to re-enter the editor."
|
---|
218 | echo $n "$0: Do you want to give up? $c"
|
---|
219 |
|
---|
220 | read ans
|
---|
221 | case "$ans" in
|
---|
222 | [Yy]*) exit 1 ;;
|
---|
223 | esac
|
---|
224 |
|
---|
225 | continue
|
---|
226 | fi
|
---|
227 |
|
---|
228 | # find the subject from the temp file and see if it's been changed
|
---|
229 | CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
|
---|
230 |
|
---|
231 | case "$CURR_SUB" in
|
---|
232 | "${INITIAL_SUBJECT}")
|
---|
233 | echo
|
---|
234 | echo "$0: You have not changed the subject from the default."
|
---|
235 | echo "$0: Please use a more descriptive subject header."
|
---|
236 | echo "$0: Type \`y' to give up, and lose your bug report;"
|
---|
237 | echo "$0: type \`n' to re-enter the editor."
|
---|
238 | echo $n "$0: Do you want to give up? $c"
|
---|
239 |
|
---|
240 | read ans
|
---|
241 | case "$ans" in
|
---|
242 | [Yy]*) exit 1 ;;
|
---|
243 | esac
|
---|
244 |
|
---|
245 | echo "$0: The editor will be restarted in five seconds."
|
---|
246 | sleep 5
|
---|
247 | edstat=1
|
---|
248 | ;;
|
---|
249 | esac
|
---|
250 |
|
---|
251 | done
|
---|
252 |
|
---|
253 | trap 'rm -rf "$TEMPDIR"; exit 1' 2 # restore trap on SIGINT
|
---|
254 |
|
---|
255 | if cmp -s "$TEMPFILE1" "$TEMPFILE2"
|
---|
256 | then
|
---|
257 | echo "File not changed, no bug report submitted."
|
---|
258 | exit
|
---|
259 | fi
|
---|
260 |
|
---|
261 | echo $n "Send bug report? [y/n] $c"
|
---|
262 | read ans
|
---|
263 | case "$ans" in
|
---|
264 | [Nn]*) exit 0 ;;
|
---|
265 | esac
|
---|
266 |
|
---|
267 | ${RMAIL} $SMARGS < "$TEMPFILE1" || {
|
---|
268 | cat "$TEMPFILE1" >> $HOME/dead.bashbug
|
---|
269 | echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
|
---|
270 | }
|
---|
271 |
|
---|
272 | exit 0
|
---|