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