| 1 | 
 #!/bin/sh - | 
 
 
 
 
 
 | 2 | 
 # | 
 
 
 
 
 
 | 3 | 
 # bashbug - create a bug report and mail it to the bug address | 
 
 
 
 
 
 | 4 | 
 # | 
 
 
 
 
 
 | 5 | 
 # The bug address depends on the release status of the shell.  Versions | 
 
 
 
 
 
 | 6 | 
 # with status `devel', `alpha', `beta', or `rc' mail bug reports to | 
 
 
 
 
 
 | 7 | 
 # chet@cwru.edu and, optionally, to bash-testers@cwru.edu. | 
 
 
 
 
 
 | 8 | 
 # Other versions send mail to bug-bash@gnu.org. | 
 
 
 
 
 
 | 9 | 
 # | 
 
 
 
 
 
 | 10 | 
 # Copyright (C) 1996-2020 Free Software Foundation, Inc. | 
 
 
 
 
 
 | 11 | 
 # | 
 
 
 
 
 
 | 12 | 
 #   This program is free software: you can redistribute it and/or modify | 
 
 
 
 
 
 | 13 | 
 #   it under the terms of the GNU General Public License as published by | 
 
 
 
 
 
 | 14 | 
 #   the Free Software Foundation, either version 3 of the License, or | 
 
 
 
 
 
 | 15 | 
 #   (at your option) any later version. | 
 
 
 
 
 
 | 16 | 
 # | 
 
 
 
 
 
 | 17 | 
 #   This program is distributed in the hope that it will be useful, | 
 
 
 
 
 
 | 18 | 
 #   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 
 
 
 
 
 | 19 | 
 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 
 
 
 
 
 | 20 | 
 #   GNU General Public License for more details. | 
 
 
 
 
 
 | 21 | 
 # | 
 
 
 
 
 
 | 22 | 
 #   You should have received a copy of the GNU General Public License | 
 
 
 
 
 
 | 23 | 
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
 
 
 
 
 
 | 24 | 
  | 
 
 
 
 
 
 | 25 | 
 # | 
 
 
 
 
 
 | 26 | 
 # configuration section: | 
 
 
 
 
 
 | 27 | 
 #       these variables are filled in by the make target in Makefile | 
 
 
 
 
 
 | 28 | 
 # | 
 
 
 
 
 
 | 29 | 
 MACHINE="x86_64" | 
 
 
 
 
 
 | 30 | 
 OS="msys" | 
 
 
 
 
 
 | 31 | 
 CC="gcc" | 
 
 
 
 
 
 | 32 | 
 CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -D_STATIC_BUILD " | 
 
 
 
 
 
 | 33 | 
 RELEASE="5.1" | 
 
 
 
 
 
 | 34 | 
 PATCHLEVEL="8" | 
 
 
 
 
 
 | 35 | 
 RELSTATUS="release" | 
 
 
 
 
 
 | 36 | 
 MACHTYPE="x86_64-pc-msys" | 
 
 
 
 
 
 | 37 | 
  | 
 
 
 
 
 
 | 38 | 
 PATH=/bin:/usr/bin:/usr/local/bin:$PATH | 
 
 
 
 
 
 | 39 | 
 export PATH | 
 
 
 
 
 
 | 40 | 
  | 
 
 
 
 
 
 | 41 | 
 # Check if TMPDIR is set, default to /tmp | 
 
 
 
 
 
 | 42 | 
 : ${TMPDIR:=/tmp} | 
 
 
 
 
 
 | 43 | 
  | 
 
 
 
 
 
 | 44 | 
 #Securely create a temporary directory for the temporary files | 
 
 
 
 
 
 | 45 | 
 TEMPDIR=$TMPDIR/bbug.$$ | 
 
 
 
 
 
 | 46 | 
 (umask 077 && mkdir "$TEMPDIR") || { | 
 
 
 
 
 
 | 47 | 
         echo "$0: could not create temporary directory" >&2 | 
 
 
 
 
 
 | 48 | 
         exit 1 | 
 
 
 
 
 
 | 49 | 
 } | 
 
 
 
 
 
 | 50 | 
  | 
 
 
 
 
 
 | 51 | 
 TEMPFILE1=$TEMPDIR/bbug1 | 
 
 
 
 
 
 | 52 | 
 TEMPFILE2=$TEMPDIR/bbug2 | 
 
 
 
 
 
 | 53 | 
          | 
 
 
 
 
 
 | 54 | 
 USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]" | 
 
 
 
 
 
 | 55 | 
 VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}" | 
 
 
 
 
 
 | 56 | 
  | 
 
 
 
 
 
 | 57 | 
 do_help= do_version= | 
 
 
 
 
 
 | 58 | 
  | 
 
 
 
 
 
 | 59 | 
 while [ $# -gt 0 ]; do | 
 
 
 
 
 
 | 60 | 
         case "$1" in | 
 
 
 
 
 
 | 61 | 
         --help)         shift ; do_help=y ;; | 
 
 
 
 
 
 | 62 | 
         --version)      shift ; do_version=y ;; | 
 
 
 
 
 
 | 63 | 
         --)             shift ; break ;; | 
 
 
 
 
 
 | 64 | 
         -*)             echo "bashbug: ${1}: invalid option" >&2 | 
 
 
 
 
 
 | 65 | 
                         echo "$USAGE" >&2 | 
 
 
 
 
 
 | 66 | 
                         exit 2 ;; | 
 
 
 
 
 
 | 67 | 
         *)              break ;; | 
 
 
 
 
 
 | 68 | 
         esac | 
 
 
 
 
 
 | 69 | 
 done | 
 
 
 
 
 
 | 70 | 
  | 
 
 
 
 
 
 | 71 | 
 if [ -n "$do_version" ]; then | 
 
 
 
 
 
 | 72 | 
         echo "${VERSTR}" | 
 
 
 
 
 
 | 73 | 
         exit 0 | 
 
 
 
 
 
 | 74 | 
 fi | 
 
 
 
 
 
 | 75 | 
  | 
 
 
 
 
 
 | 76 | 
 if [ -n "$do_help" ]; then | 
 
 
 
 
 
 | 77 | 
         echo "${VERSTR}" | 
 
 
 
 
 
 | 78 | 
         echo "${USAGE}" | 
 
 
 
 
 
 | 79 | 
         echo | 
 
 
 
 
 
 | 80 | 
         cat << HERE_EOF | 
 
 
 
 
 
 | 81 | 
 Bashbug is used to send mail to the Bash maintainers | 
 
 
 
 
 
 | 82 | 
 for when Bash doesn't behave like you'd like, or expect. | 
 
 
 
 
 
 | 83 | 
  | 
 
 
 
 
 
 | 84 | 
 Bashbug will start up your editor (as defined by the shell's | 
 
 
 
 
 
 | 85 | 
 EDITOR environment variable) with a preformatted bug report | 
 
 
 
 
 
 | 86 | 
 template for you to fill in. The report will be mailed to the | 
 
 
 
 
 
 | 87 | 
 bug-bash mailing list by default. See the manual for details. | 
 
 
 
 
 
 | 88 | 
  | 
 
 
 
 
 
 | 89 | 
 If you invoke bashbug by accident, just quit your editor without | 
 
 
 
 
 
 | 90 | 
 saving any changes to the template, and no bug report will be sent. | 
 
 
 
 
 
 | 91 | 
 HERE_EOF | 
 
 
 
 
 
 | 92 | 
         exit 0 | 
 
 
 
 
 
 | 93 | 
 fi | 
 
 
 
 
 
 | 94 | 
  | 
 
 
 
 
 
 | 95 | 
 # Figure out how to echo a string without a trailing newline | 
 
 
 
 
 
 | 96 | 
 N=`echo 'hi there\c'` | 
 
 
 
 
 
 | 97 | 
 case "$N" in | 
 
 
 
 
 
 | 98 | 
 *c)     n=-n c= ;; | 
 
 
 
 
 
 | 99 | 
 *)      n= c='\c' ;; | 
 
 
 
 
 
 | 100 | 
 esac | 
 
 
 
 
 
 | 101 | 
  | 
 
 
 
 
 
 | 102 | 
 BASHTESTERS="bash-testers@cwru.edu" | 
 
 
 
 
 
 | 103 | 
  | 
 
 
 
 
 
 | 104 | 
 case "$RELSTATUS" in | 
 
 
 
 
 
 | 105 | 
 alpha*|beta*|devel*|rc*)        BUGBASH=chet@cwru.edu ;; | 
 
 
 
 
 
 | 106 | 
 *)                              BUGBASH=bug-bash@gnu.org ;; | 
 
 
 
 
 
 | 107 | 
 esac | 
 
 
 
 
 
 | 108 | 
  | 
 
 
 
 
 
 | 109 | 
 case "$RELSTATUS" in | 
 
 
 
 
 
 | 110 | 
 alpha*|beta*|devel*|rc*) | 
 
 
 
 
 
 | 111 | 
                 echo "$0: This is a testing release.  Would you like your bug report" | 
 
 
 
 
 
 | 112 | 
                 echo "$0: to be sent to the bash-testers mailing list?" | 
 
 
 
 
 
 | 113 | 
                 echo $n "$0: Send to bash-testers? $c" | 
 
 
 
 
 
 | 114 | 
                 read ans | 
 
 
 
 
 
 | 115 | 
                 case "$ans" in | 
 
 
 
 
 
 | 116 | 
                 y*|Y*)  BUGBASH="${BUGBASH},${BASHTESTERS}" ;; | 
 
 
 
 
 
 | 117 | 
                 esac ;; | 
 
 
 
 
 
 | 118 | 
 esac | 
 
 
 
 
 
 | 119 | 
  | 
 
 
 
 
 
 | 120 | 
 BUGADDR="${1-$BUGBASH}" | 
 
 
 
 
 
 | 121 | 
  | 
 
 
 
 
 
 | 122 | 
 if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then | 
 
 
 
 
 
 | 123 | 
         if [ -x /usr/bin/editor ]; then | 
 
 
 
 
 
 | 124 | 
                 DEFEDITOR=editor | 
 
 
 
 
 
 | 125 | 
         elif [ -x /usr/local/bin/ce ]; then | 
 
 
 
 
 
 | 126 | 
                 DEFEDITOR=ce | 
 
 
 
 
 
 | 127 | 
         elif [ -x /usr/local/bin/emacs ]; then | 
 
 
 
 
 
 | 128 | 
                 DEFEDITOR=emacs | 
 
 
 
 
 
 | 129 | 
         elif [ -x /usr/contrib/bin/emacs ]; then | 
 
 
 
 
 
 | 130 | 
                 DEFEDITOR=emacs | 
 
 
 
 
 
 | 131 | 
         elif [ -x /usr/bin/emacs ]; then | 
 
 
 
 
 
 | 132 | 
                 DEFEDITOR=emacs | 
 
 
 
 
 
 | 133 | 
         elif [ -x /usr/bin/xemacs ]; then | 
 
 
 
 
 
 | 134 | 
                 DEFEDITOR=xemacs | 
 
 
 
 
 
 | 135 | 
         elif [ -x /usr/bin/nano ]; then | 
 
 
 
 
 
 | 136 | 
                 DEFEDITOR=nano | 
 
 
 
 
 
 | 137 | 
         elif [ -x /usr/contrib/bin/jove ]; then | 
 
 
 
 
 
 | 138 | 
                 DEFEDITOR=jove | 
 
 
 
 
 
 | 139 | 
         elif [ -x /usr/local/bin/jove ]; then | 
 
 
 
 
 
 | 140 | 
                 DEFEDITOR=jove | 
 
 
 
 
 
 | 141 | 
         elif [ -x /usr/bin/vi ]; then | 
 
 
 
 
 
 | 142 | 
                 DEFEDITOR=vi | 
 
 
 
 
 
 | 143 | 
         else | 
 
 
 
 
 
 | 144 | 
                 echo "$0: No default editor found: attempting to use vi" >&2 | 
 
 
 
 
 
 | 145 | 
                 DEFEDITOR=vi | 
 
 
 
 
 
 | 146 | 
         fi | 
 
 
 
 
 
 | 147 | 
 fi | 
 
 
 
 
 
 | 148 | 
  | 
 
 
 
 
 
 | 149 | 
  | 
 
 
 
 
 
 | 150 | 
 : ${EDITOR=$DEFEDITOR} | 
 
 
 
 
 
 | 151 | 
  | 
 
 
 
 
 
 | 152 | 
 : ${USER=${LOGNAME-`whoami`}} | 
 
 
 
 
 
 | 153 | 
  | 
 
 
 
 
 
 | 154 | 
 trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15 | 
 
 
 
 
 
 | 155 | 
 trap 'rm -rf "$TEMPDIR"' 0 | 
 
 
 
 
 
 | 156 | 
  | 
 
 
 
 
 
 | 157 | 
 UN= | 
 
 
 
 
 
 | 158 | 
 if (uname) >/dev/null 2>&1; then | 
 
 
 
 
 
 | 159 | 
         UN=`uname -a` | 
 
 
 
 
 
 | 160 | 
 fi | 
 
 
 
 
 
 | 161 | 
  | 
 
 
 
 
 
 | 162 | 
 if [ -f /usr/lib/sendmail ] ; then | 
 
 
 
 
 
 | 163 | 
         RMAIL="/usr/lib/sendmail" | 
 
 
 
 
 
 | 164 | 
         SMARGS="-i -t" | 
 
 
 
 
 
 | 165 | 
 elif [ -f /usr/sbin/sendmail ] ; then | 
 
 
 
 
 
 | 166 | 
         RMAIL="/usr/sbin/sendmail" | 
 
 
 
 
 
 | 167 | 
         SMARGS="-i -t" | 
 
 
 
 
 
 | 168 | 
 else | 
 
 
 
 
 
 | 169 | 
         RMAIL=rmail | 
 
 
 
 
 
 | 170 | 
         SMARGS="$BUGADDR" | 
 
 
 
 
 
 | 171 | 
 fi | 
 
 
 
 
 
 | 172 | 
  | 
 
 
 
 
 
 | 173 | 
 INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]' | 
 
 
 
 
 
 | 174 | 
  | 
 
 
 
 
 
 | 175 | 
 cat > "$TEMPFILE1" <<EOF | 
 
 
 
 
 
 | 176 | 
 From: ${USER} | 
 
 
 
 
 
 | 177 | 
 To: ${BUGADDR} | 
 
 
 
 
 
 | 178 | 
 Subject: ${INITIAL_SUBJECT} | 
 
 
 
 
 
 | 179 | 
  | 
 
 
 
 
 
 | 180 | 
 Configuration Information [Automatically generated, do not change]: | 
 
 
 
 
 
 | 181 | 
 Machine: $MACHINE | 
 
 
 
 
 
 | 182 | 
 OS: $OS | 
 
 
 
 
 
 | 183 | 
 Compiler: $CC | 
 
 
 
 
 
 | 184 | 
 Compilation CFLAGS: $CFLAGS | 
 
 
 
 
 
 | 185 | 
 uname output: $UN | 
 
 
 
 
 
 | 186 | 
 Machine Type: $MACHTYPE | 
 
 
 
 
 
 | 187 | 
  | 
 
 
 
 
 
 | 188 | 
 Bash Version: $RELEASE | 
 
 
 
 
 
 | 189 | 
 Patch Level: $PATCHLEVEL | 
 
 
 
 
 
 | 190 | 
 Release Status: $RELSTATUS | 
 
 
 
 
 
 | 191 | 
  | 
 
 
 
 
 
 | 192 | 
 Description: | 
 
 
 
 
 
 | 193 | 
         [Detailed description of the problem, suggestion, or complaint.] | 
 
 
 
 
 
 | 194 | 
  | 
 
 
 
 
 
 | 195 | 
 Repeat-By: | 
 
 
 
 
 
 | 196 | 
         [Describe the sequence of events that causes the problem | 
 
 
 
 
 
 | 197 | 
         to occur.] | 
 
 
 
 
 
 | 198 | 
  | 
 
 
 
 
 
 | 199 | 
 Fix: | 
 
 
 
 
 
 | 200 | 
         [Description of how to fix the problem.  If you don't know a | 
 
 
 
 
 
 | 201 | 
         fix for the problem, don't include this section.] | 
 
 
 
 
 
 | 202 | 
 EOF | 
 
 
 
 
 
 | 203 | 
  | 
 
 
 
 
 
 | 204 | 
 cp "$TEMPFILE1" "$TEMPFILE2" | 
 
 
 
 
 
 | 205 | 
 chmod u+w "$TEMPFILE1" | 
 
 
 
 
 
 | 206 | 
  | 
 
 
 
 
 
 | 207 | 
 trap '' 2               # ignore interrupts while in editor | 
 
 
 
 
 
 | 208 | 
  | 
 
 
 
 
 
 | 209 | 
 edstat=1 | 
 
 
 
 
 
 | 210 | 
 while [ $edstat -ne 0 ]; do | 
 
 
 
 
 
 | 211 | 
         $EDITOR "$TEMPFILE1" | 
 
 
 
 
 
 | 212 | 
         edstat=$? | 
 
 
 
 
 
 | 213 | 
  | 
 
 
 
 
 
 | 214 | 
         if [ $edstat -ne 0 ]; then | 
 
 
 
 
 
 | 215 | 
                 echo "$0: editor \`$EDITOR' exited with nonzero status." | 
 
 
 
 
 
 | 216 | 
                 echo "$0: Perhaps it was interrupted." | 
 
 
 
 
 
 | 217 | 
                 echo "$0: Type \`y' to give up, and lose your bug report;" | 
 
 
 
 
 
 | 218 | 
                 echo "$0: type \`n' to re-enter the editor." | 
 
 
 
 
 
 | 219 | 
                 echo $n "$0: Do you want to give up? $c" | 
 
 
 
 
 
 | 220 | 
  | 
 
 
 
 
 
 | 221 | 
                 read ans | 
 
 
 
 
 
 | 222 | 
                 case "$ans" in | 
 
 
 
 
 
 | 223 | 
                 [Yy]*) exit 1 ;; | 
 
 
 
 
 
 | 224 | 
                 esac | 
 
 
 
 
 
 | 225 | 
  | 
 
 
 
 
 
 | 226 | 
                 continue | 
 
 
 
 
 
 | 227 | 
         fi | 
 
 
 
 
 
 | 228 | 
  | 
 
 
 
 
 
 | 229 | 
         # find the subject from the temp file and see if it's been changed | 
 
 
 
 
 
 | 230 | 
         CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[    ]*||' | sed 1q` | 
 
 
 
 
 
 | 231 | 
  | 
 
 
 
 
 
 | 232 | 
         case "$CURR_SUB" in | 
 
 
 
 
 
 | 233 | 
         "${INITIAL_SUBJECT}") | 
 
 
 
 
 
 | 234 | 
                 echo | 
 
 
 
 
 
 | 235 | 
                 echo "$0: You have not changed the subject from the default." | 
 
 
 
 
 
 | 236 | 
                 echo "$0: Please use a more descriptive subject header." | 
 
 
 
 
 
 | 237 | 
                 echo "$0: Type \`y' to give up, and lose your bug report;" | 
 
 
 
 
 
 | 238 | 
                 echo "$0: type \`n' to re-enter the editor." | 
 
 
 
 
 
 | 239 | 
                 echo $n "$0: Do you want to give up? $c" | 
 
 
 
 
 
 | 240 | 
  | 
 
 
 
 
 
 | 241 | 
                 read ans | 
 
 
 
 
 
 | 242 | 
                 case "$ans" in | 
 
 
 
 
 
 | 243 | 
                 [Yy]*) exit 1 ;; | 
 
 
 
 
 
 | 244 | 
                 esac | 
 
 
 
 
 
 | 245 | 
  | 
 
 
 
 
 
 | 246 | 
                 echo "$0:  The editor will be restarted in five seconds." | 
 
 
 
 
 
 | 247 | 
                 sleep 5 | 
 
 
 
 
 
 | 248 | 
                 edstat=1 | 
 
 
 
 
 
 | 249 | 
                 ;; | 
 
 
 
 
 
 | 250 | 
         esac | 
 
 
 
 
 
 | 251 | 
  | 
 
 
 
 
 
 | 252 | 
 done | 
 
 
 
 
 
 | 253 | 
  | 
 
 
 
 
 
 | 254 | 
 trap 'rm -rf "$TEMPDIR"; exit 1' 2      # restore trap on SIGINT | 
 
 
 
 
 
 | 255 | 
  | 
 
 
 
 
 
 | 256 | 
 if cmp -s "$TEMPFILE1" "$TEMPFILE2" | 
 
 
 
 
 
 | 257 | 
 then | 
 
 
 
 
 
 | 258 | 
         echo "File not changed, no bug report submitted." | 
 
 
 
 
 
 | 259 | 
         exit | 
 
 
 
 
 
 | 260 | 
 fi | 
 
 
 
 
 
 | 261 | 
  | 
 
 
 
 
 
 | 262 | 
 echo $n "Send bug report to ${BUGADDR}? [y/n] $c" | 
 
 
 
 
 
 | 263 | 
 read ans | 
 
 
 
 
 
 | 264 | 
 case "$ans" in | 
 
 
 
 
 
 | 265 | 
 [Nn]*)  exit 0 ;; | 
 
 
 
 
 
 | 266 | 
 esac | 
 
 
 
 
 
 | 267 | 
  | 
 
 
 
 
 
 | 268 | 
 ${RMAIL} $SMARGS < "$TEMPFILE1" || { | 
 
 
 
 
 
 | 269 | 
         cat "$TEMPFILE1" >> $HOME/dead.bashbug | 
 
 
 
 
 
 | 270 | 
         echo "$0: mail to ${BUGADDR} failed: report saved in $HOME/dead.bashbug" >&2 | 
 
 
 
 
 
 | 271 | 
         echo "$0: please send it manually to ${BUGADDR}" >&2 | 
 
 
 
 
 
 | 272 | 
 } | 
 
 
 
 
 
 | 273 | 
  | 
 
 
 
 
 
 | 274 | 
 exit 0 |