* fvwm/fvwm2.1: Fixes to the font section
[fvwm.git] / utils / fvwmbug.in
blobf7eba5f777d082786b07fa62a2d992a70f322bba
1 #!/bin/sh -
3 # fvwmbug - create a bug report and mail it to the bug address
4 # - adapted from equivalent `bashbug' script
6 # The bug address could depend on the release status of FVWM. Currently
7 # it doesn't.
10 PATH=/bin:/usr/bin:/usr/local/bin:$PATH
11 export PATH
13 : ${EDITOR=emacs}
15 TEMP=/tmp/fvwmbug.$$
17 # Figure out how to echo a string without a trailing newline
18 N=`echo 'hi there\c'`
19 case "$N" in
20 *c) n=-n c= ;;
21 *) n= c='\c' ;;
22 esac
24 trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
25 trap 'rm -f $TEMP $TEMP.x' 0
27 # Who is mail from?
28 : ${USER=${LOGNAME-`whoami`}}
30 # Who is mail to?
31 if test $# -eq 1 ; then
32 BUGADDR=$1
33 elif test $# -eq 0 ; then
34 LOCAL=@LOCAL_BUGADDR@
35 WORKERS=fvwm-workers@fvwm.org
37 if test "$LOCAL"; then
38 echo "Do you want to send the report to the local maintainer <$LOCAL>,"
39 echo "the FVWM workers <$WORKERS>, or both?"
40 echo $n "Send report to (l)ocal, (w)orkers, (b)oth? " $c
41 read ans
42 case "$ans" in
43 l*|L*) BUGADDR=$LOCAL;;
44 f*|F*|w*|W*) BUGADDR=$WORKERS;;
45 b*|B*) BUGADDR=$LOCAL,$WORKERS;;
46 *) echo "[Defaulting to LOCAL]"; BUGADDR=$LOCAL;;
47 esac
49 else
50 echo >&2 "usage: fvwmbug [address]"
51 exit 1
54 UN=
55 if (uname) >/dev/null 2>&1; then
56 UN=`uname -a`
59 if [ -f /usr/lib/sendmail ] ; then
60 RMAIL="/usr/lib/sendmail"
61 elif [ -f /usr/sbin/sendmail ] ; then
62 RMAIL="/usr/sbin/sendmail"
63 else
64 RMAIL=rmail
68 prefix=@prefix@
69 exec_prefix=@exec_prefix@
70 datadir=@datadir@
71 libexecdir=@libexecdir@
72 : ${FVWM_USERDIR=unset}
73 FVWM_DATADIR=@FVWM_DATADIR@
74 FVWM_MODULEDIR=@FVWM_MODULEDIR@
77 cat > $TEMP <<EOF
78 From: ${USER}
79 To: ${BUGADDR}
80 Subject: [50 character or so descriptive subject here (for reference)]
82 Configuration Information [Automatically generated, do not change]:
83 uname: $UN
84 compiler flags: @CC@ @CFLAGS@
86 FVWM Version: @VERSION@
87 FVWM_MODULEDIR: $FVWM_MODULEDIR
88 FVWM_DATADIR: $FVWM_DATADIR
89 FVWM_USERDIR: $FVWM_USERDIR
91 Description:
92 [Detailed description of the problem, suggestion, or complaint.]
94 Repeat-By:
95 [Describe the sequence of events that causes the problem
96 to occur.]
98 Fix:
99 [Description of how to fix the problem. If you don't know a
100 fix for the problem, don't include this section.]
103 chmod u+w $TEMP
104 cp $TEMP $TEMP.x
106 trap '' 2 # ignore interrupts while in editor
108 until $EDITOR $TEMP; do
109 echo "$0: editor \`$EDITOR' exited with nonzero status."
110 echo "$0: Perhaps it was interrupted."
111 echo "$0: Type \`y' to give up, and lose your bug report;"
112 echo "$0: type \`n' to re-enter the editor."
113 echo $n "$0: Do you want to give up? $c"
115 read ans
116 case "$ans" in
117 [Yy]*) exit 1 ;;
118 esac
119 done
121 trap 'rm -f $TEMP $TEMP.x; exit 1' 2 # restore trap on SIGINT
123 if cmp -s $TEMP $TEMP.x
124 then
125 echo "File not changed, no bug report submitted."
126 exit
129 echo $n "Send bug report? [y/n] $c"
130 read ans
131 case "$ans" in
132 [Nn]*) exit 0 ;;
133 esac
135 ${RMAIL} $BUGADDR < $TEMP || {
136 cat $TEMP >> $HOME/dead.fvwmbug
137 echo "$0: mail failed: report saved in $HOME/dead.fvwmbug" >&2
140 exit 0