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 DEFS=%OCTAVE_CONF_DEFS% |
797
|
60 |
3082
|
61 : ${USER=$LOGNAME} |
|
62 |
2031
|
63 CC_AND_VERSION= |
|
64 if test -n "$CC_VERSION"; then |
|
65 CC_AND_VERSION="$CC, version $CC_VERSION" |
|
66 fi |
|
67 |
|
68 CXX_AND_VERSION= |
|
69 if test -n "$CXX_VERSION"; then |
|
70 CXX_AND_VERSION="$CXX, version $CXX_VERSION" |
|
71 fi |
|
72 |
846
|
73 PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:$PATH |
797
|
74 export PATH |
|
75 |
|
76 TEMP=/tmp/octave-bug.$$ |
|
77 |
5111
|
78 if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then |
|
79 if [ -x /usr/bin/editor ]; then |
|
80 DEFEDITOR=editor |
|
81 elif [ -x /usr/local/bin/ce ]; then |
|
82 DEFEDITOR=ce |
|
83 elif [ -x /usr/local/bin/emacs ]; then |
|
84 DEFEDITOR=emacs |
|
85 elif [ -x /usr/contrib/bin/emacs ]; then |
|
86 DEFEDITOR=emacs |
|
87 elif [ -x /usr/bin/emacs ]; then |
|
88 DEFEDITOR=emacs |
|
89 elif [ -x /usr/bin/xemacs ]; then |
|
90 DEFEDITOR=xemacs |
|
91 elif [ -x /usr/contrib/bin/jove ]; then |
|
92 DEFEDITOR=jove |
|
93 elif [ -x /usr/local/bin/jove ]; then |
|
94 DEFEDITOR=jove |
|
95 elif [ -x /usr/bin/vi ]; then |
|
96 DEFEDITOR=vi |
|
97 else |
|
98 echo "octave-bug: No default editor found: attempting to use vi" >&2 |
|
99 DEFEDITOR=vi |
|
100 fi |
|
101 fi |
|
102 |
|
103 : ${EDITOR=$DEFEDITOR} |
|
104 |
5229
|
105 if [ -z "$DEFPAGER" ] && [ -z "$PAGER" ]; then |
|
106 if [ -x /usr/bin/pager ]; then |
|
107 DEFPAGER=pager |
|
108 elif [ -x /usr/bin/less ]; then |
|
109 DEFPAGER=less |
5230
|
110 elif [ -x /bin/less ]; then |
5229
|
111 DEFPAGER=less |
|
112 elif [ -x /usr/local/bin/less ]; then |
|
113 DEFPAGER=less |
|
114 elif [ -x /usr/bin/more ]; then |
|
115 DEFPAGER=more |
|
116 elif [ -x /bin/more ]; then |
|
117 DEFPAGER=more |
|
118 elif [ -x /usr/bin/pg ]; then |
|
119 DEFPAGER=pg |
|
120 elif [ -x /bin/pg ]; then |
|
121 DEFPAGER=pg |
|
122 else |
|
123 echo "octave-bug: No default pager found: attempting to use more" >&2 |
|
124 DEFPAGER=more |
|
125 fi |
|
126 fi |
|
127 |
|
128 : ${PAGER=$DEFPAGER} |
797
|
129 |
|
130 trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15 |
|
131 trap 'rm -f $TEMP $TEMP.x' 0 |
|
132 |
|
133 UN= |
2222
|
134 if (uname) > /dev/null 2>&1; then |
797
|
135 UN=`uname -a` |
|
136 fi |
|
137 |
|
138 HAVE_FMT=false |
2222
|
139 if (fmt < /dev/null) > /dev/null 2>&1; then |
797
|
140 HAVE_FMT=true |
|
141 fi |
|
142 |
2564
|
143 # Check whether to use -n or \c to keep echo from printing a newline |
|
144 # character. Stolen from autoconf, which borrowed the idea from dist 3.0. |
|
145 |
|
146 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then |
|
147 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. |
4084
|
148 if (echo -n testing; echo 1,2,3) | $SED s/-n/xn/ | grep xn >/dev/null; then |
2564
|
149 echo_n= |
|
150 echo_c=' |
|
151 ' |
|
152 else |
|
153 echo_n=-n |
|
154 echo_c= |
|
155 fi |
|
156 else |
|
157 echo_n= |
|
158 echo_c='\c' |
|
159 fi |
|
160 |
801
|
161 ss_p=`echo $VERSION | grep "^ss-"` |
2222
|
162 if test -n "$ss_p"; then |
5041
|
163 BUGADDR="maintainers@octave.org" |
801
|
164 else |
2691
|
165 pretest_p=`echo $VERSION \ |
4084
|
166 | $SED 's,.*\.\([0-9]*\).*,\1,' \ |
2691
|
167 | grep -v '\.' \ |
|
168 | grep '[0-9]'` |
2222
|
169 |
|
170 if test -n "$pretest_p" && test "$pretest_p" -ge 90; then |
5041
|
171 BUGADDR="maintainers@octave.org" |
2222
|
172 else |
5041
|
173 BUGADDR="bug@octave.org" |
2222
|
174 fi |
801
|
175 fi |
797
|
176 |
|
177 SUBJECT="[50 character or so descriptive subject here (for reference)]" |
2222
|
178 if test $# -gt 0; then |
797
|
179 case "$1" in |
|
180 -s) |
801
|
181 shift |
2222
|
182 if test $# -gt 0; then |
797
|
183 SUBJECT="$1" |
801
|
184 shift |
797
|
185 else |
|
186 echo "usage: octave-bug [-s subject]" |
|
187 exit 1 |
|
188 fi |
|
189 ;; |
|
190 esac |
|
191 fi |
|
192 |
|
193 cat > $TEMP << EOF |
|
194 To: $BUGADDR |
3082
|
195 EOF |
|
196 if test -n "$USER"; then |
|
197 cat >> $TEMP << EOF |
|
198 Cc: $USER |
|
199 EOF |
|
200 fi |
|
201 cat >> $TEMP << EOF |
797
|
202 Subject: $SUBJECT |
851
|
203 -------- |
797
|
204 Bug report for Octave $VERSION configured for $MACHINE |
|
205 |
|
206 Description: |
|
207 ----------- |
|
208 |
|
209 * Please replace this item with a detailed description of the |
|
210 problem. Suggestions or general comments are also welcome. |
|
211 |
|
212 Repeat-By: |
|
213 --------- |
|
214 |
|
215 * Please replace this item with a description of the sequence of |
|
216 events that causes the problem to occur. |
|
217 |
|
218 Fix: |
|
219 --- |
|
220 |
|
221 * If possible, replace this item with a description of how to |
|
222 fix the problem (if you don't have a fix for the problem, don't |
|
223 include this section, but please do submit your report anyway). |
|
224 |
801
|
225 |
|
226 |
|
227 Configuration (please do not edit this section): |
|
228 ----------------------------------------------- |
|
229 |
|
230 uname output: $UN |
2155
|
231 configure opts: $config_opts |
801
|
232 Fortran compiler: $F77 |
|
233 FFLAGS: $FFLAGS |
1064
|
234 F2C: $F2C |
|
235 F2CFLAGS: $F2CFLAGS |
|
236 FLIBS: $FLIBS |
2155
|
237 CPPFLAGS: $CPPFLAGS |
|
238 INCFLAGS: $INCFLAGS |
2031
|
239 C compiler: $CC_AND_VERSION |
801
|
240 CFLAGS: $CFLAGS |
2155
|
241 CPICFLAG: $CPICFLAG |
2031
|
242 C++ compiler: $CXX_AND_VERSION |
801
|
243 CXXFLAGS: $CXXFLAGS |
2155
|
244 CXXPICFLAG: $CXXPICFLAG |
3859
|
245 LD_CXX: $LD_CXX |
1064
|
246 LDFLAGS: $LDFLAGS |
2155
|
247 LIBFLAGS: $LIBFLAGS |
2676
|
248 RLD_FLAG: $RLD_FLAG |
3859
|
249 BLAS_LIBS: $BLAS_LIBS |
|
250 FFTW_LIBS: $FFTW_LIBS |
2155
|
251 LIBS: $LIBS |
|
252 LEXLIB: $LEXLIB |
3215
|
253 LIBGLOB: $LIBGLOB |
4084
|
254 SED: $SED |
801
|
255 DEFS: |
|
256 |
797
|
257 EOF |
|
258 |
2222
|
259 if $HAVE_FMT; then |
4084
|
260 echo $DEFS | fmt | $SED 's/^/ /' >> $TEMP |
801
|
261 else |
|
262 echo $DEFS >> $TEMP |
|
263 fi |
|
264 |
2222
|
265 if test $# -gt 0; then |
|
266 if test -f "$1"; then |
801
|
267 cat >> $TEMP << EOF |
|
268 |
|
269 User-preferences (please do not edit this section): |
|
270 -------------------------------------------------- |
|
271 |
|
272 EOF |
|
273 cat $1 >> $TEMP |
|
274 fi |
|
275 fi |
|
276 |
797
|
277 chmod u+w $TEMP |
|
278 cp $TEMP $TEMP.x |
|
279 |
|
280 status=0 |
|
281 |
2564
|
282 editing=true |
|
283 |
|
284 while $editing; do |
|
285 if $EDITOR $TEMP; then |
|
286 while $editing; do |
|
287 echo $echo_n "(a)bort, (e)dit, (l)ist, (s)end? $echo_c" |
|
288 read ans |
|
289 case "$ans" in |
|
290 a* | A*) |
|
291 status=1 |
|
292 editing=false |
|
293 ;; |
|
294 e* | E*) |
|
295 break; |
|
296 ;; |
|
297 l* | L*) |
|
298 $PAGER $TEMP |
|
299 ;; |
|
300 s* | S*) |
|
301 editing=false |
|
302 ;; |
|
303 esac |
|
304 done |
|
305 else |
|
306 echo "problems with edit -- no bug report submitted" |
|
307 status=1 |
|
308 editing=false |
|
309 fi |
|
310 done |
|
311 |
|
312 if test $status -eq 0; then |
2222
|
313 if cmp -s $TEMP $TEMP.x; then |
797
|
314 echo "file not changed -- no bug report submitted" |
|
315 status=1 |
2031
|
316 elif test `wc $TEMP | awk '{print $1}'` -eq 0; then |
|
317 echo "empty bug report file -- not submitted" |
|
318 status=1 |
797
|
319 else |
851
|
320 |
|
321 # Try to extract the recipient address, in case the To: line in the |
964
|
322 # message template has been changed. Also get cc: lines. |
851
|
323 |
4084
|
324 TO_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Tt][Oo]://p'` |
|
325 CC_ADDR=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^[Cc][Cc]://p'` |
964
|
326 |
2222
|
327 if test -z "$TO_ADDR"; then |
851
|
328 echo "no valid \`To:' field found in header -- using $BUGADDR instead" |
|
329 else |
964
|
330 BUGADDR="$TO_ADDR" |
851
|
331 fi |
|
332 |
964
|
333 BUGADDR="$BUGADDR $CC_ADDR" |
|
334 |
4084
|
335 TMP_SUB=`$SED -e '/^--------[ \t]*$/q' $TEMP | $SED -n -e 's/^Subject://p'` |
2564
|
336 |
|
337 if test -n "$TMP_SUB"; then |
|
338 SUBJECT="$TMP_SUB" |
|
339 fi |
|
340 |
851
|
341 # Delete the `--------' separator in the message. |
|
342 |
1066
|
343 # Don't pretty-print this. Odd whitespace kills Ultrix AWK! |
|
344 |
|
345 awk 'BEGIN{in_header=1;} /^--------[ \t]*$/ { |
|
346 if (in_header) { in_header=0; print ""; next; } |
|
347 } { print $0; }' $TEMP > $TEMP.x |
851
|
348 |
|
349 # Now try to mail it. |
|
350 |
7171
|
351 # indicate that we have not yet sent email successfully |
|
352 status=11 |
|
353 |
1066
|
354 if test $status -ne 0; then |
7171
|
355 ( mailx -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
356 status=$? |
|
357 if test $status -ne 0; then |
7171
|
358 ( Mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
|
359 status=$? |
|
360 if test $status -ne 0; then |
|
361 ( /usr/ucb/mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
|
362 status=$? |
|
363 # make /bin/mail our last resort -- it ignores the subject line |
|
364 if test $status -ne 0; then |
|
365 ( /bin/mail $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
|
366 status=$? |
|
367 if test $status -ne 0; then |
|
368 echo "unable to send mail..." |
|
369 fi |
|
370 fi |
|
371 fi |
1066
|
372 fi |
|
373 fi |
797
|
374 fi |
2564
|
375 fi |
|
376 |
|
377 if test $status -ne 0; then |
3082
|
378 dead_bug_file=$HOME/dead-octave-bug |
|
379 looking_for_file=true; |
|
380 n=1 |
|
381 while $looking_for_file; do |
|
382 if test -f "$dead_bug_file-$n"; then |
|
383 n=`expr $n + 1` |
|
384 else |
|
385 looking_for_file=false |
|
386 dead_bug_file=$dead_bug_file-$n |
|
387 fi |
|
388 done |
|
389 echo "saving message in $dead_bug_file"; |
|
390 cat $TEMP >> $dead_bug_file; |
2564
|
391 exit 1 |
797
|
392 else |
2564
|
393 echo "bug report sent to: $TO_ADDR" |
|
394 echo " cc to: $CC_ADDR" |
797
|
395 fi |
|
396 |
|
397 exit $status |