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