source: trunk/athena/bin/sendbug/sendbug.sh @ 25582

Revision 25582, 4.1 KB checked in by jdreed, 13 years ago (diff)
In sendbug: * Make the bug report questions clearer, give the user some guidance on using archaic TTY editors
Line 
1#!/bin/sh
2# $Id: sendbug.sh,v 1.21 2003-07-30 19:16:12 zacheiss Exp $
3
4visual=false
5
6help () {
7    echo "Usage: $0 [program]"
8    echo "Assist a user in sending an accurate and useful bug report."
9}
10
11TEMP="$(getopt -n "$0" -o '' -l gnome,help -- "$@")" || exit $?
12eval set -- "$TEMP"
13
14while true; do
15    case "$1" in
16        # This is how we are invoked from the panel menu
17        --gnome) gnome=true; shift;;
18        --help) help; exit;;
19        --) shift; break;;
20    esac
21done
22
23subject=$1
24bugs_address=bugs@mit.edu
25sendmail="/usr/sbin/sendmail -t -oi"
26report_file=$(mktemp -t "sendbug.$USER.XXXX")
27machtype=$(machtype)
28cpu=$(machtype -c)
29hostname=$(hostname)
30dpy=$(machtype -d)
31
32localacct=
33shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null`
34if [ -z "$shell" ]; then
35    shell=`getent passwd $USER 2>/dev/null | cut -d ':' -f 7`
36else
37    localacct="(local account)"
38fi
39case $shell in
40$SHELL)
41  ;;
42"")
43  shell="$SHELL (?)"
44  ;;
45*)
46  shell="$shell ($SHELL?)"
47  ;;
48esac
49
50if [ -z "$subject" ]; then
51  text="Please enter the name of the program or locker with which you are"
52  text="$text having problems."
53  if [ true = "$gnome" ]; then
54      if ! subject=$(zenity --entry --text="$text"); then
55          exit
56      fi
57  else
58    echo "$text" || fmt
59    echo -n ' --> '
60    read subject
61  fi
62fi
63
64cat > $report_file << EOF
65To: $bugs_address
66Subject: Debathena: $subject
67
68System name:            $hostname
69Type:                   $cpu
70Display type:           $dpy
71
72Shell:                  $shell $localacct
73Window manager:         ${WINDOW_MANAGER:-unknown}
74Desktop session:        ${GDMSESSION:-unknown}
75
761) What were you trying to do?
77
78
792) What happened?
80
81
823) What should have happened?
83
84
854) Does this problem happen only on this workstation, or other workstations?
86
87
885) If you were following instructions, please include the URL or a
89   description of the documentation:
90   (e.g. a "problem set for 18.03" or http://ist.mit.edu)
91
92
93EOF
94
95if [ true = "$gnome" ]; then
96  text="After you click OK, an editor window will appear with the bug report"
97  text="$text contents.  Please fill out the form, then save and exit.  If"
98  text="$text you change your mind, you will have a chance to cancel before"
99  text="$text the bug report is sent."
100  zenity --info --text="$text"
101  gnome-text-editor "$report_file"
102  # zenity doesn't let us specify the buttons on a question, and the
103  # list dialog is awkward.  So while we'd like to do something more
104  # like what we do in the terminal case, we'll compromise a bit.
105  question="Do you still want to send the bug report?"
106  if ! zenity --question --text="$question"; then
107    text="Cancelled.  Your text is in $report_file if you wish to recover it."
108    zenity --info --no-wrap --text="$text"
109    exit
110  fi
111
112  if $sendmail < $report_file; then
113    text="Thank you for your bug report."
114    zenity --info --text="$text"
115  else
116    text="Failed to send the bug report!  Please contact olc@mit.edu for"
117    text="$text\nassistance.  Your text is in $report_file"
118    text="$text\nif you wish to recover it and submit it to $bugs_address"
119    zenity --error --no-wrap --text="$text"
120  fi
121else
122  : ${EDITOR=nano}
123  helpstr=
124  case "$EDITOR" in
125    nano|pico)
126      helpstr="(Ctrl-O, then Enter to save; Ctrl-X to quit after saving)"
127      ;;
128    emacs)
129      helpstr="(Ctrl-X, Ctrl-S to save; Ctrl-X, Ctrl-C to quit after saving)"
130      ;;
131  esac
132  fmt << EOF
133
134After you press <Enter>, an editor will now open with the bug report
135form.  Some fields have been filled out already.  Please answer the
136numbered questions with as much detail as possible. 
137Remember to save the file before exiting the editor. 
138$helpstr
139
140Press <Enter> to continue.
141EOF
142  read dummy
143  $EDITOR "$report_file"
144  while true; do
145    fmt << EOF
146
147Please enter "send" to send the report, "edit" to re-edit it, or
148"quit" to quit.
149EOF
150    echo -n ' --> '
151    read reply
152    [ send = "$reply" ] && break
153    [ quit = "$reply" ] && exit
154    [ edit = "$reply" ] && $EDITOR "$report_file"
155  done
156
157  if $sendmail < $report_file; then
158    echo "Thank you for your bug report."
159  else
160    fmt << EOF
161Failed to send the bug report!  This shouldn't happen!
162Your text is in $report_file if you wish to recover it,
163and you can submit it to $bugs_address.
164EOF
165  fi
166fi
Note: See TracBrowser for help on using the repository browser.