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.
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
[13428]32shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null`
[13018]33case $shell in
34$SHELL)
[23088]35  ;;
[13018]36"")
[23088]37  shell="$SHELL (?)"
38  ;;
[13018]39*)
[23088]40  shell="$shell ($SHELL?)"
41  ;;
[13018]42esac
43
[18057]44if [ -z "$subject" ]; then
[23088]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
[23633]48      if ! subject=$(zenity --entry --text="$text"); then
49          exit
50      fi
[23088]51  else
52    echo "$text" || fmt
53    echo -n ' --> '
54    read subject
55  fi
[18057]56fi
57
[2433]58cat > $report_file << EOF
59To: $bugs_address
[23924]60Subject: Debathena: $subject
[23088]61
[2433]62System name:            $hostname
[23088]63Type:                   $cpu
64Display type:           $dpy
[2447]65
[13018]66Shell:                  $shell
67Window manager:         ${WINDOW_MANAGER:-unknown}
68
[2433]69What were you trying to do?
[2447]70        [Please replace this line with your information.]
[5]71
[2433]72What's wrong:
[2447]73        [Please replace this line with your information.]
[2433]74
75What should have happened:
[2447]76        [Please replace this line with your information.]
[2433]77
78Please describe any relevant documentation references:
[2447]79        [Please replace this line with your information.]
[2433]80EOF
81
[23088]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
[2433]98
[23088]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
[2433]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
[23088]115  : ${EDITOR=emacs}
116  $EDITOR "$report_file"
117  while true; do
118    fmt << EOF
[2433]119
[23088]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
[2433]129
[23088]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.