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

Revision 25414, 3.5 KB checked in by adehnert, 13 years ago (diff)
In sendbug: * Add a --help option. (http://diswww.mit.edu/menelaus/bugs/27568) * Fix the manpage to not reference MH. * Bump the compatibility level to 6.
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
32shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null`
33case $shell in
34$SHELL)
35  ;;
36"")
37  shell="$SHELL (?)"
38  ;;
39*)
40  shell="$shell ($SHELL?)"
41  ;;
42esac
43
44if [ -z "$subject" ]; then
45  text="Please enter the name of the program or locker with which you are"
46  text="$text having problems."
47  if [ true = "$gnome" ]; then
48      if ! subject=$(zenity --entry --text="$text"); then
49          exit
50      fi
51  else
52    echo "$text" || fmt
53    echo -n ' --> '
54    read subject
55  fi
56fi
57
58cat > $report_file << EOF
59To: $bugs_address
60Subject: Debathena: $subject
61
62System name:            $hostname
63Type:                   $cpu
64Display type:           $dpy
65
66Shell:                  $shell
67Window manager:         ${WINDOW_MANAGER:-unknown}
68
69What were you trying to do?
70        [Please replace this line with your information.]
71
72What's wrong:
73        [Please replace this line with your information.]
74
75What should have happened:
76        [Please replace this line with your information.]
77
78Please describe any relevant documentation references:
79        [Please replace this line with your information.]
80EOF
81
82if [ true = "$gnome" ]; then
83  text="After you click OK, an editor window will appear with the bug report"
84  text="$text contents.  Please fill out the form, then save and exit.  If"
85  text="$text you change your mind, you will have a chance to cancel before"
86  text="$text the bug report is sent."
87  zenity --info --text="$text"
88  gnome-text-editor "$report_file"
89  # zenity doesn't let us specify the buttons on a question, and the
90  # list dialog is awkward.  So while we'd like to do something more
91  # like what we do in the terminal case, we'll compromise a bit.
92  question="Do you still want to send the bug report?"
93  if ! zenity --question --text="$question"; then
94    text="Cancelled.  Your text is in $report_file if you wish to recover it."
95    zenity --info --no-wrap --text="$text"
96    exit
97  fi
98
99  if $sendmail < $report_file; then
100    text="Thank you for your bug report."
101    zenity --info --text="$text"
102  else
103    text="Failed to send the bug report!  Please contact x3-4435 for"
104    text="$text\nassistance.  Your text is in $report_file"
105    text="$text\nif you wish to recover it."
106    zenity --error --no-wrap --text="$text"
107  fi
108else
109  fmt << EOF
110
111Please fill in the specified fields of the bug report form, which will
112be displayed momentarily.
113Remember to save the file before exiting the editor.
114EOF
115  : ${EDITOR=emacs}
116  $EDITOR "$report_file"
117  while true; do
118    fmt << EOF
119
120Please enter "send" to send the report, "edit" to re-edit it, or
121"quit" to quit.
122EOF
123    echo -n ' --> '
124    read reply
125    [ send = "$reply" ] && break
126    [ quit = "$reply" ] && exit
127    [ edit = "$reply" ] && $EDITOR "$report_file"
128  done
129
130  if $sendmail < $report_file; then
131    echo "Thank you for your bug report."
132  else
133    fmt << EOF
134Failed to send the bug report!  Please contact x3-4435 for assistance.
135Your text is in $report_file if you wish to recover it.
136EOF
137  fi
138fi
Note: See TracBrowser for help on using the repository browser.