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

Revision 23633, 3.2 KB checked in by broder, 16 years ago (diff)
In sendbug: * If a user clicks "cancel" in the zenity dialog, actually quit. (Trac: #157)
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
5if [ x--gnome = x"$1" ]; then
6  # This is how we are invoked from the panel menu
7  gnome=true
8  shift
[2433]9fi
[23088]10subject=$1
11bugs_address=bugs@mit.edu
12sendmail="/usr/sbin/sendmail -t -oi"
13report_file=$(mktemp -t "sendbug.$USER.XXXX")
14machtype=$(machtype)
15cpu=$(machtype -c)
16hostname=$(hostname)
17dpy=$(machtype -d)
[13018]18
[13428]19shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null`
[13018]20case $shell in
21$SHELL)
[23088]22  ;;
[13018]23"")
[23088]24  shell="$SHELL (?)"
25  ;;
[13018]26*)
[23088]27  shell="$shell ($SHELL?)"
28  ;;
[13018]29esac
30
[18057]31if [ -z "$subject" ]; then
[23088]32  text="Please enter the name of the program or locker with which you are"
33  text="$text having problems."
34  if [ true = "$gnome" ]; then
[23633]35      if ! subject=$(zenity --entry --text="$text"); then
36          exit
37      fi
[23088]38  else
39    echo "$text" || fmt
40    echo -n ' --> '
41    read subject
42  fi
[18057]43fi
44
[2433]45cat > $report_file << EOF
46To: $bugs_address
[23526]47Subject: Debathena Beta: $subject
[23088]48
[2433]49System name:            $hostname
[23088]50Type:                   $cpu
51Display type:           $dpy
[2447]52
[13018]53Shell:                  $shell
54Window manager:         ${WINDOW_MANAGER:-unknown}
55
[2433]56What were you trying to do?
[2447]57        [Please replace this line with your information.]
[5]58
[2433]59What's wrong:
[2447]60        [Please replace this line with your information.]
[2433]61
62What should have happened:
[2447]63        [Please replace this line with your information.]
[2433]64
65Please describe any relevant documentation references:
[2447]66        [Please replace this line with your information.]
[2433]67EOF
68
[23088]69if [ true = "$gnome" ]; then
70  text="After you click OK, an editor window will appear with the bug report"
71  text="$text contents.  Please fill out the form, then save and exit.  If"
72  text="$text you change your mind, you will have a chance to cancel before"
73  text="$text the bug report is sent."
74  zenity --info --text="$text"
75  gnome-text-editor "$report_file"
76  # zenity doesn't let us specify the buttons on a question, and the
77  # list dialog is awkward.  So while we'd like to do something more
78  # like what we do in the terminal case, we'll compromise a bit.
79  question="Do you still want to send the bug report?"
80  if ! zenity --question --text="$question"; then
81    text="Cancelled.  Your text is in $report_file if you wish to recover it."
82    zenity --info --no-wrap --text="$text"
83    exit
84  fi
[2433]85
[23088]86  if $sendmail < $report_file; then
87    text="Thank you for your bug report."
88    zenity --info --text="$text"
89  else
90    text="Failed to send the bug report!  Please contact x3-4435 for"
91    text="$text\nassistance.  Your text is in $report_file"
92    text="$text\nif you wish to recover it."
93    zenity --error --no-wrap --text="$text"
94  fi
95else
96  fmt << EOF
97
[2433]98Please fill in the specified fields of the bug report form, which will
99be displayed momentarily.
100Remember to save the file before exiting the editor.
101EOF
[23088]102  : ${EDITOR=emacs}
103  $EDITOR "$report_file"
104  while true; do
105    fmt << EOF
[2433]106
[23088]107Please enter "send" to send the report, "edit" to re-edit it, or
108"quit" to quit.
109EOF
110    echo -n ' --> '
111    read reply
112    [ send = "$reply" ] && break
113    [ quit = "$reply" ] && exit
114    [ edit = "$reply" ] && $EDITOR "$report_file"
115  done
[2433]116
[23088]117  if $sendmail < $report_file; then
118    echo "Thank you for your bug report."
119  else
120    fmt << EOF
121Failed to send the bug report!  Please contact x3-4435 for assistance.
122Your text is in $report_file if you wish to recover it.
123EOF
124  fi
125fi
Note: See TracBrowser for help on using the repository browser.