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
RevLine 
[5]1#!/bin/sh
[19702]2# $Id: sendbug.sh,v 1.21 2003-07-30 19:16:12 zacheiss Exp $
[8670]3
[23088]4visual=false
[25414]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
[23088]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)
[13018]31
[25582]32localacct=
[13428]33shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null`
[25582]34if [ -z "$shell" ]; then
35    shell=`getent passwd $USER 2>/dev/null | cut -d ':' -f 7`
36else
37    localacct="(local account)"
38fi
[13018]39case $shell in
40$SHELL)
[23088]41  ;;
[13018]42"")
[23088]43  shell="$SHELL (?)"
44  ;;
[13018]45*)
[23088]46  shell="$shell ($SHELL?)"
47  ;;
[13018]48esac
49
[18057]50if [ -z "$subject" ]; then
[23088]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
[23633]54      if ! subject=$(zenity --entry --text="$text"); then
55          exit
56      fi
[23088]57  else
58    echo "$text" || fmt
59    echo -n ' --> '
60    read subject
61  fi
[18057]62fi
63
[2433]64cat > $report_file << EOF
65To: $bugs_address
[23924]66Subject: Debathena: $subject
[23088]67
[2433]68System name:            $hostname
[23088]69Type:                   $cpu
70Display type:           $dpy
[2447]71
[25582]72Shell:                  $shell $localacct
[13018]73Window manager:         ${WINDOW_MANAGER:-unknown}
[25582]74Desktop session:        ${GDMSESSION:-unknown}
[13018]75
[25582]761) What were you trying to do?
[5]77
[2433]78
[25582]792) What happened?
[2433]80
[25582]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
[2433]93EOF
94
[23088]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
[2433]111
[23088]112  if $sendmail < $report_file; then
113    text="Thank you for your bug report."
114    zenity --info --text="$text"
115  else
[25582]116    text="Failed to send the bug report!  Please contact olc@mit.edu for"
[23088]117    text="$text\nassistance.  Your text is in $report_file"
[25582]118    text="$text\nif you wish to recover it and submit it to $bugs_address"
[23088]119    zenity --error --no-wrap --text="$text"
120  fi
121else
[25582]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
[23088]132  fmt << EOF
133
[25582]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.
[2433]141EOF
[25582]142  read dummy
[23088]143  $EDITOR "$report_file"
144  while true; do
145    fmt << EOF
[2433]146
[23088]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
[2433]156
[23088]157  if $sendmail < $report_file; then
158    echo "Thank you for your bug report."
159  else
160    fmt << EOF
[25582]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.
[23088]164EOF
165  fi
166fi
Note: See TracBrowser for help on using the repository browser.