bashbug 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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-2004 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 2, or (at your option)
  15. # 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, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
  25. #
  26. # configuration section:
  27. # these variables are filled in by the make target in Makefile
  28. #
  29. MACHINE="arm"
  30. OS="linux-gnueabi"
  31. CC="arm-linux-gnueabihf-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard "
  32. CFLAGS=" -DPROGRAM='bash' -DCONF_HOSTTYPE='arm' -DCONF_OSTYPE='linux-gnueabi' -DCONF_MACHTYPE='arm-unknown-linux-gnueabi' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash-3.2.57 -I../bash-3.2.57/include -I../bash-3.2.57/lib -isystem/home/gtbldadm/tools/linaro-2016.11/arm-linux-gnueabihf/include -isystem/home/gtbldadm/tools/linaro-2016.11/arm-linux-gnueabihf/include -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/oe/bld/build-CORTEX_1/arago-tmp-external-linaro-toolchain/work/armv7ahf-neon-linux-gnueabi/bash/3.2.57-r0.arago0=/usr/src/debug/bash/3.2.57-r0.arago0 -fdebug-prefix-map=/oe/bld/build-CORTEX_1/arago-tmp-external-linaro-toolchain/sysroots/x86_64-linux= -fdebug-prefix-map=/oe/bld/build-CORTEX_1/arago-tmp-external-linaro-toolchain/sysroots/am335x-evm= -DNON_INTERACTIVE_LOGIN_SHELLS"
  33. RELEASE="3.2"
  34. PATCHLEVEL="57"
  35. RELSTATUS="release"
  36. MACHTYPE="arm-unknown-linux-gnueabi"
  37. PATH=/bin:/usr/bin:/usr/local/bin:$PATH
  38. export PATH
  39. # Check if TMPDIR is set, default to /tmp
  40. : ${TMPDIR:=/tmp}
  41. #Securely create a temporary directory for the temporary files
  42. TEMPDIR=$TMPDIR/bbug.$$
  43. (umask 077 && mkdir $TEMPDIR) || {
  44. echo "$0: could not create temporary directory" >&2
  45. exit 1
  46. }
  47. TEMPFILE1=$TEMPDIR/bbug1
  48. TEMPFILE2=$TEMPDIR/bbug2
  49. USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"
  50. VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
  51. do_help= do_version=
  52. while [ $# -gt 0 ]; do
  53. case "$1" in
  54. --help) shift ; do_help=y ;;
  55. --version) shift ; do_version=y ;;
  56. --) shift ; break ;;
  57. -*) echo "bashbug: ${1}: invalid option" >&2
  58. echo "$USAGE" >& 2
  59. exit 2 ;;
  60. *) break ;;
  61. esac
  62. done
  63. if [ -n "$do_version" ]; then
  64. echo "${VERSTR}"
  65. exit 0
  66. fi
  67. if [ -n "$do_help" ]; then
  68. echo "${VERSTR}"
  69. echo "${USAGE}"
  70. echo
  71. cat << HERE_EOF
  72. Bashbug is used to send mail to the Bash maintainers
  73. for when Bash doesn't behave like you'd like, or expect.
  74. Bashbug will start up your editor (as defined by the shell's
  75. EDITOR environment variable) with a preformatted bug report
  76. template for you to fill in. The report will be mailed to the
  77. bash maintainers by default. See the manual for details.
  78. If you invoke bashbug by accident, just quit your editor without
  79. saving any changes to the template, and no bug report will be sent.
  80. HERE_EOF
  81. exit 0
  82. fi
  83. # Figure out how to echo a string without a trailing newline
  84. N=`echo 'hi there\c'`
  85. case "$N" in
  86. *c) n=-n c= ;;
  87. *) n= c='\c' ;;
  88. esac
  89. BASHTESTERS="bash-testers@cwru.edu"
  90. case "$RELSTATUS" in
  91. alpha*|beta*|devel*|rc*) BUGBASH=chet@cwru.edu ;;
  92. *) BUGBASH=bug-bash@gnu.org ;;
  93. esac
  94. case "$RELSTATUS" in
  95. alpha*|beta*|devel*|rc*)
  96. echo "$0: This is a testing release. Would you like your bug report"
  97. echo "$0: to be sent to the bash-testers mailing list?"
  98. echo $n "$0: Send to bash-testers? $c"
  99. read ans
  100. case "$ans" in
  101. y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
  102. esac ;;
  103. esac
  104. BUGADDR="${1-$BUGBASH}"
  105. if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
  106. if [ -x /usr/bin/editor ]; then
  107. DEFEDITOR=editor
  108. elif [ -x /usr/local/bin/ce ]; then
  109. DEFEDITOR=ce
  110. elif [ -x /usr/local/bin/emacs ]; then
  111. DEFEDITOR=emacs
  112. elif [ -x /usr/contrib/bin/emacs ]; then
  113. DEFEDITOR=emacs
  114. elif [ -x /usr/bin/emacs ]; then
  115. DEFEDITOR=emacs
  116. elif [ -x /usr/bin/xemacs ]; then
  117. DEFEDITOR=xemacs
  118. elif [ -x /usr/contrib/bin/jove ]; then
  119. DEFEDITOR=jove
  120. elif [ -x /usr/local/bin/jove ]; then
  121. DEFEDITOR=jove
  122. elif [ -x /usr/bin/vi ]; then
  123. DEFEDITOR=vi
  124. else
  125. echo "$0: No default editor found: attempting to use vi" >&2
  126. DEFEDITOR=vi
  127. fi
  128. fi
  129. : ${EDITOR=$DEFEDITOR}
  130. : ${USER=${LOGNAME-`whoami`}}
  131. trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15
  132. trap 'rm -rf "$TEMPDIR"' 0
  133. UN=
  134. if (uname) >/dev/null 2>&1; then
  135. UN=`uname -a`
  136. fi
  137. if [ -f /usr/lib/sendmail ] ; then
  138. RMAIL="/usr/lib/sendmail"
  139. SMARGS="-i -t"
  140. elif [ -f /usr/sbin/sendmail ] ; then
  141. RMAIL="/usr/sbin/sendmail"
  142. SMARGS="-i -t"
  143. else
  144. RMAIL=rmail
  145. SMARGS="$BUGADDR"
  146. fi
  147. INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'
  148. cat > "$TEMPFILE1" <<EOF
  149. From: ${USER}
  150. To: ${BUGADDR}
  151. Subject: ${INITIAL_SUBJECT}
  152. Configuration Information [Automatically generated, do not change]:
  153. Machine: $MACHINE
  154. OS: $OS
  155. Compiler: $CC
  156. Compilation CFLAGS: $CFLAGS
  157. uname output: $UN
  158. Machine Type: $MACHTYPE
  159. Bash Version: $RELEASE
  160. Patch Level: $PATCHLEVEL
  161. Release Status: $RELSTATUS
  162. Description:
  163. [Detailed description of the problem, suggestion, or complaint.]
  164. Repeat-By:
  165. [Describe the sequence of events that causes the problem
  166. to occur.]
  167. Fix:
  168. [Description of how to fix the problem. If you don't know a
  169. fix for the problem, don't include this section.]
  170. EOF
  171. cp "$TEMPFILE1" "$TEMPFILE2"
  172. chmod u+w "$TEMPFILE1"
  173. trap '' 2 # ignore interrupts while in editor
  174. edstat=1
  175. while [ $edstat -ne 0 ]; do
  176. $EDITOR "$TEMPFILE1"
  177. edstat=$?
  178. if [ $edstat -ne 0 ]; then
  179. echo "$0: editor \`$EDITOR' exited with nonzero status."
  180. echo "$0: Perhaps it was interrupted."
  181. echo "$0: Type \`y' to give up, and lose your bug report;"
  182. echo "$0: type \`n' to re-enter the editor."
  183. echo $n "$0: Do you want to give up? $c"
  184. read ans
  185. case "$ans" in
  186. [Yy]*) exit 1 ;;
  187. esac
  188. continue
  189. fi
  190. # find the subject from the temp file and see if it's been changed
  191. CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
  192. case "$CURR_SUB" in
  193. "${INITIAL_SUBJECT}")
  194. echo
  195. echo "$0: You have not changed the subject from the default."
  196. echo "$0: Please use a more descriptive subject header."
  197. echo "$0: Type \`y' to give up, and lose your bug report;"
  198. echo "$0: type \`n' to re-enter the editor."
  199. echo $n "$0: Do you want to give up? $c"
  200. read ans
  201. case "$ans" in
  202. [Yy]*) exit 1 ;;
  203. esac
  204. echo "$0: The editor will be restarted in five seconds."
  205. sleep 5
  206. edstat=1
  207. ;;
  208. esac
  209. done
  210. trap 'rm -rf "$TEMPDIR"; exit 1' 2 # restore trap on SIGINT
  211. if cmp -s "$TEMPFILE1" "$TEMPFILE2"
  212. then
  213. echo "File not changed, no bug report submitted."
  214. exit
  215. fi
  216. echo $n "Send bug report? [y/n] $c"
  217. read ans
  218. case "$ans" in
  219. [Nn]*) exit 0 ;;
  220. esac
  221. ${RMAIL} $SMARGS < "$TEMPFILE1" || {
  222. cat "$TEMPFILE1" >> $HOME/dead.bashbug
  223. echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
  224. }
  225. exit 0