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