#!/bin/sh - # # bashbug - create a bug report and mail it to the bug address # # The bug address depends on the release status of the shell. Versions # with status `devel', `alpha', `beta', or `rc' mail bug reports to # chet@po.cwru.edu and, optionally, to bash-testers@po.cwru.edu. # Other versions send mail to bug-bash@gnu.org. # # configuration section: # these variables are filled in by the make target in Makefile # MACHINE="!MACHINE!" OS="!OS!" CC="!CC!" CFLAGS="!CFLAGS!" RELEASE="!RELEASE!" PATCHLEVEL="!PATCHLEVEL!" RELSTATUS="!RELSTATUS!" MACHTYPE="!MACHTYPE!" PATH=/bin:/usr/bin:/usr/local/bin:$PATH export PATH # If the OS supplies a program to make temp files with semi-random names, # use it. : ${TMPDIR:=/tmp} rm_tmp1=false rm_tmp2=false # if we don't have mktemp or tempfile, we don't want to see error messages # like `mktemp: not found', so temporarily redirect stderr using {...} while # trying to run them. this may fail using old versions of the bourne shell # that run {...} blocks with redirections in subshells; in that case we're # no worse off than previous versions { TEMPFILE1=`mktemp "$TMPDIR/bbug.XXXXXX" 2>/dev/null` ; } 2>/dev/null if [ -z "$TEMPFILE1" ]; then { TEMPFILE1=`tempfile --prefix bbug --mode 600 2>/dev/null`; } 2>/dev/null fi if [ -z "$TEMPFILE1" ]; then TEMPFILE1=$TMPDIR/bbug.$$ rm_tmp1=true fi { TEMPFILE2=`mktemp "$TMPDIR/bbug.XXXXXX" 2>/dev/null`; } 2>/dev/null if [ -z "$TEMPFILE2" ]; then { TEMPFILE2=`tempfile --prefix bbug --mode 600 2>/dev/null`; } 2>/dev/null fi if [ -z "$TEMPFILE2" ]; then TEMPFILE2="$TMPDIR/bbug.$$.x" rm_tmp2=true fi USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]" VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}" do_help= do_version= while [ $# -gt 0 ]; do case "$1" in --help) shift ; do_help=y ;; --version) shift ; do_version=y ;; --) shift ; break ;; -*) echo "bashbug: ${1}: invalid option" >&2 echo "$USAGE" >& 2 exit 2 ;; *) break ;; esac done if [ -n "$do_version" ]; then echo "${VERSTR}" exit 0 fi if [ -n "$do_help" ]; then echo "${VERSTR}" echo "${USAGE}" echo cat << HERE_EOF Bashbug is used to send mail to the Bash maintainers for when Bash doesn't behave like you'd like, or expect. Bashbug will start up your editor (as defined by the shell's EDITOR environment variable) with a preformatted bug report template for you to fill in. The report will be mailed to the bash maintainers by default. See the manual for details. If you invoke bashbug by accident, just quit your editor without saving any changes to the template, and no bug report will be sent. HERE_EOF exit 0 fi # Figure out how to echo a string without a trailing newline N=`echo 'hi there\c'` case "$N" in *c) n=-n c= ;; *) n= c='\c' ;; esac BASHTESTERS="bash-testers@po.cwru.edu" case "$RELSTATUS" in alpha*|beta*|devel*|rc*) BUGBASH=chet@po.cwru.edu ;; *) BUGBASH=bug-bash@gnu.org ;; esac case "$RELSTATUS" in alpha*|beta*|devel*|rc*) echo "$0: This is a testing release. Would you like your bug report" echo "$0: to be sent to the bash-testers mailing list?" echo $n "$0: Send to bash-testers? $c" read ans case "$ans" in y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;; esac ;; esac BUGADDR="${1-$BUGBASH}" if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then if [ -x /usr/bin/editor ]; then DEFEDITOR=editor elif [ -x /usr/local/bin/ce ]; then DEFEDITOR=ce elif [ -x /usr/local/bin/emacs ]; then DEFEDITOR=emacs elif [ -x /usr/contrib/bin/emacs ]; then DEFEDITOR=emacs elif [ -x /usr/bin/emacs ]; then DEFEDITOR=emacs elif [ -x /usr/bin/xemacs ]; then DEFEDITOR=xemacs elif [ -x /usr/contrib/bin/jove ]; then DEFEDITOR=jove elif [ -x /usr/local/bin/jove ]; then DEFEDITOR=jove elif [ -x /usr/bin/vi ]; then DEFEDITOR=vi else echo "$0: No default editor found: attempting to use vi" >&2 DEFEDITOR=vi fi fi : ${EDITOR=$DEFEDITOR} : ${USER=${LOGNAME-`whoami`}} trap 'rm -f "$TEMPFILE1" "$TEMPFILE2"; exit 1' 1 2 3 13 15 trap 'rm -f "$TEMPFILE1" "$TEMPFILE2"' 0 UN= if (uname) >/dev/null 2>&1; then UN=`uname -a` fi if [ -f /usr/lib/sendmail ] ; then RMAIL="/usr/lib/sendmail" SMARGS="-i -t" elif [ -f /usr/sbin/sendmail ] ; then RMAIL="/usr/sbin/sendmail" SMARGS="-i -t" else RMAIL=rmail SMARGS="$BUGADDR" fi INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]' # this is raceable unless (hopefully) we used mktemp(1) or tempfile(1) $rm_tmp1 && rm -f "$TEMPFILE1" cat > "$TEMPFILE1" <> $HOME/dead.bashbug echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2 } exit 0