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