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 |
|
9 # jwe@che.utexas.edu |
|
10 # Department of Chemical Engineering |
|
11 # The University of Texas at Austin |
|
12 |
|
13 # Configuration: these variables are filled in at configuration time. |
|
14 |
|
15 VERSION="%VERSION%" |
|
16 MACHINE="%TARGET_HOST_TYPE%" |
|
17 F77="%F77%" |
|
18 FFLAGS="%FFLAGS%" |
1064
|
19 FLIBS="%FLIBS%" |
|
20 F2C="%F2C%" |
|
21 F2CFLAGS="%F2CFLAGS%" |
797
|
22 CC="%CC%" |
|
23 CFLAGS="%CFLAGS%" |
|
24 CXX="%CXX%" |
|
25 CXXFLAGS="%CXXFLAGS%" |
1064
|
26 LDFLAGS="%LDFLAGS%" |
797
|
27 DEFS="%DEFS%" |
|
28 |
846
|
29 PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:$PATH |
797
|
30 export PATH |
|
31 |
|
32 TEMP=/tmp/octave-bug.$$ |
|
33 |
|
34 : ${EDITOR=emacs} |
|
35 |
|
36 trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15 |
|
37 trap 'rm -f $TEMP $TEMP.x' 0 |
|
38 |
|
39 UN= |
|
40 if (uname) > /dev/null 2>&1 |
|
41 then |
|
42 UN=`uname -a` |
|
43 fi |
|
44 |
|
45 HAVE_FMT=false |
|
46 if (fmt < /dev/null) > /dev/null 2>&1 |
|
47 then |
|
48 HAVE_FMT=true |
|
49 fi |
|
50 |
801
|
51 ss_p=`echo $VERSION | grep "^ss-"` |
|
52 if test -n "$ss_p" |
|
53 then |
|
54 BUGADDR="octave-maintainers@che.utexas.edu" |
|
55 else |
|
56 BUGADDR="bug-octave@che.utexas.edu" |
|
57 fi |
797
|
58 |
|
59 SUBJECT="[50 character or so descriptive subject here (for reference)]" |
|
60 if test $# -gt 0 |
|
61 then |
|
62 case "$1" in |
|
63 -s) |
801
|
64 shift |
797
|
65 if test $# -gt 0 |
|
66 then |
|
67 SUBJECT="$1" |
801
|
68 shift |
797
|
69 else |
|
70 echo "usage: octave-bug [-s subject]" |
|
71 exit 1 |
|
72 fi |
|
73 ;; |
|
74 esac |
|
75 fi |
|
76 |
|
77 cat > $TEMP << EOF |
|
78 To: $BUGADDR |
|
79 Subject: $SUBJECT |
851
|
80 -------- |
797
|
81 Bug report for Octave $VERSION configured for $MACHINE |
|
82 |
|
83 Description: |
|
84 ----------- |
|
85 |
|
86 * Please replace this item with a detailed description of the |
|
87 problem. Suggestions or general comments are also welcome. |
|
88 |
|
89 Repeat-By: |
|
90 --------- |
|
91 |
|
92 * Please replace this item with a description of the sequence of |
|
93 events that causes the problem to occur. |
|
94 |
|
95 Fix: |
|
96 --- |
|
97 |
|
98 * If possible, replace this item with a description of how to |
|
99 fix the problem (if you don't have a fix for the problem, don't |
|
100 include this section, but please do submit your report anyway). |
|
101 |
801
|
102 |
|
103 |
|
104 Configuration (please do not edit this section): |
|
105 ----------------------------------------------- |
|
106 |
|
107 uname output: $UN |
|
108 Fortran compiler: $F77 |
|
109 FFLAGS: $FFLAGS |
1064
|
110 F2C: $F2C |
|
111 F2CFLAGS: $F2CFLAGS |
|
112 FLIBS: $FLIBS |
801
|
113 C compiler: $CC |
|
114 CFLAGS: $CFLAGS |
|
115 C++ compiler: $CXX |
|
116 CXXFLAGS: $CXXFLAGS |
1064
|
117 LDFLAGS: $LDFLAGS |
801
|
118 DEFS: |
|
119 |
797
|
120 EOF |
|
121 |
801
|
122 if $HAVE_FMT |
|
123 then |
|
124 echo $DEFS | fmt | sed 's/^/ /' >> $TEMP |
|
125 else |
|
126 echo $DEFS >> $TEMP |
|
127 fi |
|
128 |
|
129 if test $# -gt 0 |
|
130 then |
|
131 if test -f "$1" |
|
132 then |
|
133 cat >> $TEMP << EOF |
|
134 |
|
135 User-preferences (please do not edit this section): |
|
136 -------------------------------------------------- |
|
137 |
|
138 EOF |
|
139 cat $1 >> $TEMP |
|
140 fi |
|
141 fi |
|
142 |
797
|
143 chmod u+w $TEMP |
|
144 cp $TEMP $TEMP.x |
|
145 |
|
146 status=0 |
|
147 |
|
148 if $EDITOR $TEMP |
|
149 then |
|
150 if cmp -s $TEMP $TEMP.x |
|
151 then |
|
152 echo "file not changed -- no bug report submitted" |
|
153 status=1 |
|
154 else |
851
|
155 |
|
156 # Try to extract the recipient address, in case the To: line in the |
964
|
157 # message template has been changed. Also get cc: lines. |
851
|
158 |
964
|
159 TO_ADDR=`sed -e '/^--------[ \t]*$/q' $TEMP | sed -n -e 's/^[Tt][Oo]://p'` |
|
160 CC_ADDR=`sed -e '/^--------[ \t]*$/q' $TEMP | sed -n -e 's/^[Cc][Cc]://p'` |
|
161 |
|
162 if test -z "$TO_ADDR" |
851
|
163 then |
|
164 echo "no valid \`To:' field found in header -- using $BUGADDR instead" |
|
165 else |
964
|
166 BUGADDR="$TO_ADDR" |
851
|
167 fi |
|
168 |
964
|
169 BUGADDR="$BUGADDR $CC_ADDR" |
|
170 |
851
|
171 # Delete the `--------' separator in the message. |
|
172 |
1066
|
173 # Don't pretty-print this. Odd whitespace kills Ultrix AWK! |
|
174 |
|
175 awk 'BEGIN{in_header=1;} /^--------[ \t]*$/ { |
|
176 if (in_header) { in_header=0; print ""; next; } |
|
177 } { print $0; }' $TEMP > $TEMP.x |
851
|
178 |
|
179 # Now try to mail it. |
|
180 |
1067
|
181 ( /bin/mail $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
182 status=$? |
|
183 if test $status -ne 0; then |
1067
|
184 ( Mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
185 status=$? |
|
186 if test $status -ne 0; then |
1067
|
187 ( /usr/ucb/mail -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
188 status=$? |
|
189 if test $status -ne 0; then |
1067
|
190 ( mailx -s "$SUBJECT" $BUGADDR < $TEMP.x ) > /dev/null 2>&1 |
1066
|
191 status=$? |
|
192 fi |
|
193 fi |
|
194 fi |
856
|
195 |
1066
|
196 if test $status -ne 0; then |
|
197 echo "unable to send mail -- saving message in \$HOME/dead.octave-bug"; |
|
198 cat $TEMP >> $HOME/dead.octave-bug; |
|
199 exit 1 |
|
200 else |
964
|
201 echo "bug report sent to: $TO_ADDR" |
|
202 echo " cc to: $CC_ADDR" |
|
203 fi |
797
|
204 fi |
|
205 else |
|
206 echo "problems with edit -- no bug report submitted" |
|
207 status=1 |
|
208 fi |
|
209 |
|
210 exit $status |