797
|
1 #! /bin/sh - |
|
2 # |
7019
|
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004, |
|
4 # 2005, 2006 John W. Eaton |
|
5 # |
|
6 # This file is part of Octave. |
|
7 # |
|
8 # Octave is free software; you can redistribute it and/or modify it |
|
9 # under the terms of the GNU General Public License as published by the |
|
10 # Free Software Foundation; either version 3 of the License, or (at |
|
11 # your option) any later version. |
|
12 # |
|
13 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 # for more details. |
|
17 # |
|
18 # You should have received a copy of the GNU General Public License |
|
19 # along with Octave; see the file COPYING. If not, see |
|
20 # <http://www.gnu.org/licenses/>. |
|
21 |
797
|
22 # octave-bug - create a bug report and mail it to the bug-octave |
|
23 # mailing list. |
|
24 # |
|
25 # Patterned after the bashbug script from bash 1.14. |
|
26 |
2155
|
27 # Configuration: these variables are filled in when running make to |
|
28 # compile Octave. |
797
|
29 |
3681
|
30 config_opts=%OCTAVE_CONF_config_opts% |
3590
|
31 VERSION=%OCTAVE_CONF_VERSION% |
4084
|
32 SED=%OCTAVE_CONF_SED% |
3768
|
33 MACHINE=%OCTAVE_CONF_CANONICAL_HOST_TYPE% |
3590
|
34 F77=%OCTAVE_CONF_F77% |
|
35 FFLAGS=%OCTAVE_CONF_FFLAGS% |
|
36 FPICFLAG=%OCTAVE_CONF_FPICFLAG% |
|
37 FLIBS=%OCTAVE_CONF_FLIBS% |
|
38 F2C=%OCTAVE_CONF_F2C% |
|
39 F2CFLAGS=%OCTAVE_CONF_F2CFLAGS% |
|
40 CPPFLAGS=%OCTAVE_CONF_CPPFLAGS% |
|
41 INCFLAGS=%OCTAVE_CONF_INCFLAGS% |
|
42 CC=%OCTAVE_CONF_CC% |
|
43 CC_VERSION=%OCTAVE_CONF_CC_VERSION% |
|
44 CFLAGS=%OCTAVE_CONF_CFLAGS% |
|
45 CPICFLAG=%OCTAVE_CONF_CPICFLAG% |
|
46 CXX=%OCTAVE_CONF_CXX% |
|
47 CXX_VERSION=%OCTAVE_CONF_CXX_VERSION% |
3681
|
48 CXXFLAGS=%OCTAVE_CONF_CXXFLAGS% |
3590
|
49 CXXPICFLAG=%OCTAVE_CONF_CXXPICFLAG% |
3859
|
50 LD_CXX=%OCTAVE_CONF_LD_CXX% |
3590
|
51 LDFLAGS=%OCTAVE_CONF_LDFLAGS% |
|
52 LIBFLAGS=%OCTAVE_CONF_LIBFLAGS% |
|
53 RLD_FLAG=%OCTAVE_CONF_RLD_FLAG% |
|
54 LIBS=%OCTAVE_CONF_LIBS% |
3859
|
55 BLAS_LIBS=%OCTAVE_CONF_BLAS_LIBS% |
|
56 FFTW_LIBS=%OCTAVE_CONF_FFTW_LIBS% |
3590
|
57 LEXLIB=%OCTAVE_CONF_LEXLIB% |
|
58 LIBGLOB=%OCTAVE_CONF_LIBGLOB% |
|
59 LIBDLFCN=%OCTAVE_CONF_LIBDLFCN% |
|
60 DEFS=%OCTAVE_CONF_DEFS% |
797
|
61 |
3082
|
62 : ${USER=$LOGNAME} |
|
63 |
2031
|
64 CC_AND_VERSION= |
|
65 if test -n "$CC_VERSION"; then |
|
66 CC_AND_VERSION="$CC, version $CC_VERSION" |
|
67 fi |
|
68 |
|
69 CXX_AND_VERSION= |
|
70 if test -n "$CXX_VERSION"; then |
|
71 CXX_AND_VERSION="$CXX, version $CXX_VERSION" |
|
72 fi |
|
73 |
846
|
74 PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:$PATH |
797
|
75 export PATH |
|
76 |
|
77 TEMP=/tmp/octave-bug.$$ |
|
78 |
5111
|
79 if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then |
|
80 if [ -x /usr/bin/editor ]; then |
|
81 DEFEDITOR=editor |
|
82 elif [ -x /usr/local/bin/ce ]; then |
|
83 DEFEDITOR=ce |
|
84 elif [ -x /usr/local/bin/emacs ]; then |
|
85 DEFEDITOR=emacs |
|
86 elif [ -x /usr/contrib/bin/emacs ]; then |
|
87 DEFEDITOR=emacs |
|
88 elif [ -x /usr/bin/emacs ]; then |
|
89 DEFEDITOR=emacs |
|
90 elif [ -x /usr/bin/xemacs ]; then |
|
91 DEFEDITOR=xemacs |
|
92 elif [ -x /usr/contrib/bin/jove ]; then |
|
93 DEFEDITOR=jove |
|
94 elif [ -x /usr/local/bin/jove ]; then |
|
95 DEFEDITOR=jove |
|
96 elif [ -x /usr/bin/vi ]; then |
|
97 DEFEDITOR=vi |
|
98 else |
|
99 echo "octave-bug: No default editor found: attempting to use vi" >&2 |
|
100 DEFEDITOR=vi |
|
101 fi |
|
102 fi |
|
103 |
|
104 : ${EDITOR=$DEFEDITOR} |
|
105 |
5229
|
106 if [ -z "$DEFPAGER" ] && [ -z "$PAGER" ]; then |
|
107 if [ -x /usr/bin/pager ]; then |
|
108 DEFPAGER=pager |
|
109 elif [ -x /usr/bin/less ]; then |
|
110 DEFPAGER=less |
5230
|
111 elif [ -x /bin/less ]; then |
5229
|
112 DEFPAGER=less |
|
113 elif [ -x /usr/local/bin/less ]; then |
|
114 DEFPAGER=less |
|
115 elif [ -x /usr/bin/more ]; then |
|
116 DEFPAGER=more |
|
117 elif [ -x /bin/more ]; then |
|
118 DEFPAGER=more |
|
119 elif [ -x /usr/bin/pg ]; then |
|
120 DEFPAGER=pg |
|
121 elif [ -x /bin/pg ]; then |
|
122 DEFPAGER=pg |
|
123 else |
|
124 echo "octave-bug: No default pager found: attempting to use more" >&2 |
|
125 DEFPAGER=more |
|
126 fi |
|
127 fi |
|
128 |
|
129 : ${PAGER=$DEFPAGER} |
797
|
130 |
|
131 trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15 |
|
132 trap 'rm -f $TEMP $TEMP.x' 0 |
|
133 |
|
134 UN= |
2222
|
135 if (uname) > /dev/null 2>&1; then |
797
|
136 UN=`uname -a` |
|
137 fi |
|
138 |
|
139 HAVE_FMT=false |
2222
|
140 if (fmt < /dev/null) > /dev/null 2>&1; then |
797
|
141 HAVE_FMT=true |
|
142 fi |
|
143 |
2564
|
144 # Check whether to use -n or \c to keep echo from printing a newline |
|
145 # character. Stolen from autoconf, which borrowed the idea from dist 3.0. |
|
146 |
|
147 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then |
|
148 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. |
4084
|
149 if (echo -n testing; echo 1,2,3) | $SED s/-n/xn/ | grep xn >/dev/null; then |
2564
|
150 echo_n= |
|
151 echo_c=' |
|
152 ' |
|
153 else |
|
154 echo_n=-n |
|
155 echo_c= |
|
156 fi |
|
157 else |
|
158 echo_n= |
|
159 echo_c='\c' |
|
160 fi |
|
161 |
801
|
162 ss_p=`echo $VERSION | grep "^ss-"` |
2222
|
163 if test -n "$ss_p"; then |
5041
|
164 BUGADDR="maintainers@octave.org" |
801
|
165 else |
2691
|
166 pretest_p=`echo $VERSION \ |
4084
|
167 | $SED 's,.*\.\([0-9]*\).*,\1,' \ |
2691
|
168 | grep -v '\.' \ |
|
169 | grep '[0-9]'` |
2222
|
170 |
|
171 if test -n "$pretest_p" && test "$pretest_p" -ge 90; then |
5041
|
172 BUGADDR="maintainers@octave.org" |
2222
|
173 else |
5041
|
174 BUGADDR="bug@octave.org" |
2222
|
175 fi |
801
|
176 fi |
797
|
177 |
|
178 SUBJECT="[50 character or so descriptive subject here (for reference)]" |
2222
|
179 if test $# -gt 0; then |
797
|
180 case "$1" in |
|
181 -s) |
801
|
182 shift |
2222
|
183 if test $# -gt 0; then |
797
|
184 SUBJECT="$1" |
801
|
185 shift |
797
|
186 else |
|
187 echo "usage: octave-bug [-s subject]" |
|
188 exit 1 |
|
189 fi |
|
190 ;; |
|
191 esac |
|
192 fi |
|
193 |
|
194 cat > $TEMP << EOF |
|
195 To: $BUGADDR |
3082
|
196 EOF |
|
197 if test -n "$USER"; then |
|
198 cat >> $TEMP << EOF |
|
199 Cc: $USER |
|
200 EOF |
|
201 fi |
|
202 cat >> $TEMP << EOF |
797
|
203 Subject: $SUBJECT |
851
|
204 -------- |
797
|
205 Bug report for Octave $VERSION configured for $MACHINE |
|
206 |
|
207 Description: |
|
208 ----------- |
|
209 |
|
210 * Please replace this item with a detailed description of the |
|
211 problem. Suggestions or general comments are also welcome. |
|
212 |
|
213 Repeat-By: |
|
214 --------- |
|
215 |
|
216 * Please replace this item with a description of the sequence of |
|
217 events that causes the problem to occur. |
|
218 |
|
219 Fix: |
|
220 --- |
|
221 |
|
222 * If possible, replace this item with a description of how to |
|
223 fix the problem (if you don't have a fix for the problem, don't |
|
224 include this section, but please do submit your report anyway). |
|
225 |
801
|
226 |
|
227 |
|
228 Configuration (please do not edit this section): |
|
229 ----------------------------------------------- |
|
230 |
|
231 uname output: $UN |
2155
|
232 configure opts: $config_opts |
801
|
233 Fortran compiler: $F77 |
|
234 FFLAGS: $FFLAGS |
1064
|
235 F2C: $F2C |
|
236 F2CFLAGS: $F2CFLAGS |
|
237 FLIBS: $FLIBS |
2155
|
238 CPPFLAGS: $CPPFLAGS |
|
239 INCFLAGS: $INCFLAGS |
2031
|
240 C compiler: $CC_AND_VERSION |
801
|
241 CFLAGS: $CFLAGS |
2155
|
242 CPICFLAG: $CPICFLAG |
2031
|
243 C++ compiler: $CXX_AND_VERSION |
801
|
244 CXXFLAGS: $CXXFLAGS |
2155
|
245 CXXPICFLAG: $CXXPICFLAG |
3859
|
246 LD_CXX: $LD_CXX |
1064
|
247 LDFLAGS: $LDFLAGS |
2155
|
248 LIBFLAGS: $LIBFLAGS |
2676
|
249 RLD_FLAG: $RLD_FLAG |
3859
|
250 BLAS_LIBS: $BLAS_LIBS |
|
251 FFTW_LIBS: $FFTW_LIBS |
2155
|
252 LIBS: $LIBS |
|
253 LEXLIB: $LEXLIB |
|
254 LIBDLFCN: $LIBDLFCN |
3215
|
255 LIBGLOB: $LIBGLOB |
4084
|
256 SED: $SED |
801
|
257 DEFS: |
|
258 |
797
|
259 EOF |
|
260 |
2222
|
261 if $HAVE_FMT; then |
4084
|
262 echo $DEFS | fmt | $SED 's/^/ /' >> $TEMP |
801
|
263 else |
|
264 echo $DEFS >> $TEMP |
|
265 fi |
|
266 |
2222
|
267 if test $# -gt 0; then |
|
268 if test -f "$1"; then |
801
|
269 cat >> $TEMP << EOF |
|
270 |
|
271 User-preferences (please do not edit this section): |
|
272 -------------------------------------------------- |
|
273 |
|
274 EOF |
|
275 cat $1 >> $TEMP |
|
276 fi |
|
277 fi |
|
278 |
797
|
279 chmod u+w $TEMP |
|
280 cp $TEMP $TEMP.x |
|
281 |
|
282 status=0 |
|
283 |
2564
|
284 editing=true |
|
285 |
|
286 while $editing; do |
|
287 if $EDITOR $TEMP; then |
|
288 while $editing; do |
|
289 echo $echo_n "(a)bort, (e)dit, (l)ist, (s)end? $echo_c" |
|
290 read ans |
|
291 case "$ans" in |
|
292 a* | A*) |
|
293 status=1 |
|
294 editing=false |
|
295 ;; |
|
296 e* | E*) |
|
297 break; |
|
298 ;; |
|
299 l* | L*) |
|
300 $PAGER $TEMP |
|
301 ;; |
|
302 s* | S*) |
|
303 editing=false |
|
304 ;; |
|
305 esac |
|
306 done |
|
307 else |
|
308 echo "problems with edit -- no bug report submitted" |
|
309 status=1 |
|
310 editing=false |
|
311 fi |
|
312 done |
|
313 |
|
314 if test $status -eq 0; then |
2222
|
315 if cmp -s $TEMP $TEMP.x; then |
797
|
316 echo "file not changed -- no bug report submitted" |
|
317 status=1 |
2031
|
318 elif test `wc $TEMP | awk '{print $1}'` -eq 0; then |
|
319 echo "empty bug report file -- not submitted" |
|
320 status=1 |
797
|
321 else |
851
|
322 |
|
323 # Try to extract the recipient address, in case the To: line in the |
964
|
324 # message template has been changed. Also get cc: lines. |
851
|
325 |
4084
|
326 TO_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Tt][Oo]://p'` |
|
327 CC_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Cc][Cc]://p'` |
964
|
328 |
2222
|
329 if test -z "$TO_ADDR"; then |
851
|
330 echo "no valid \`To:' field found in header -- using $BUGADDR instead" |
|
331 else |
964
|
332 BUGADDR="$TO_ADDR" |
851
|
333 fi |
|
334 |
964
|
335 BUGADDR="$BUGADDR $CC_ADDR" |
|
336 |
4084
|
337 TMP_SUB=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^Subject://p'` |
2564
|
338 |
|
339 if test -n "$TMP_SUB"; then |
|
340 SUBJECT="$TMP_SUB" |
|
341 fi |
|
342 |
851
|
343 # Delete the `--------' separator in the message. |
|
344 |
1066
|
345 # Don't pretty-print this. Odd whitespace kills Ultrix AWK! |
|
346 |
|
347 awk 'BEGIN{in_header=1;} /^--------[ \t]*$/ { |
|
348 if (in_header) { in_header=0; print ""; next; } |
|
349 } { print $0; }' $TEMP > $TEMP.x |
851
|
350 |
|
351 # Now try to mail it. |
|
352 |
1067
|
353 ( /bin/mail $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
354 status=$? |
|
355 if test $status -ne 0; then |
1067
|
356 ( Mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
357 status=$? |
|
358 if test $status -ne 0; then |
2564
|
359 ( /usr/ucb/mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
|
360 status=$? |
|
361 if test $status -ne 0; then |
|
362 ( mailx -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
|
363 status=$? |
|
364 fi |
1066
|
365 fi |
|
366 fi |
856
|
367 |
1066
|
368 if test $status -ne 0; then |
2564
|
369 echo "unable to send mail..." |
964
|
370 fi |
797
|
371 fi |
2564
|
372 fi |
|
373 |
|
374 if test $status -ne 0; then |
3082
|
375 dead_bug_file=$HOME/dead-octave-bug |
|
376 looking_for_file=true; |
|
377 n=1 |
|
378 while $looking_for_file; do |
|
379 if test -f "$dead_bug_file-$n"; then |
|
380 n=`expr $n + 1` |
|
381 else |
|
382 looking_for_file=false |
|
383 dead_bug_file=$dead_bug_file-$n |
|
384 fi |
|
385 done |
|
386 echo "saving message in $dead_bug_file"; |
|
387 cat $TEMP >> $dead_bug_file; |
2564
|
388 exit 1 |
797
|
389 else |
2564
|
390 echo "bug report sent to: $TO_ADDR" |
|
391 echo " cc to: $CC_ADDR" |
797
|
392 fi |
|
393 |
|
394 exit $status |