Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
gawkbug290 linesDownload Raw Back to bin
1#!/bin/sh -2#3# gawkbug - create a bug report and mail it to the bug address4#5# All mail defaults to bug-gawk@gnu.org. Unlike the original bashbug6# script, we don't differentiate on the release status.7#8# Copyright (C) 1996-2022 Free Software Foundation, Inc.9#10#   This program is free software: you can redistribute it and/or modify11#   it under the terms of the GNU General Public License as published by12#   the Free Software Foundation, either version 3 of the License, or13#   (at your option) any later version.14#15#   This program is distributed in the hope that it will be useful,16#   but WITHOUT ANY WARRANTY; without even the implied warranty of17#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the18#   GNU General Public License for more details.19#20#   You should have received a copy of the GNU General Public License21#   along with this program.  If not, see <http://www.gnu.org/licenses/>.22 23#24# configuration section:25#	these variables are filled in by the make target in Makefile26#27MACHINE="x86_64"28OS="msys"29CC="gcc"30CFLAGS="-march=nocona -msahf -mtune=generic -O2 -pipe"31VERSION="5.4.0"32MACHTYPE="x86_64-pc-msys"33 34PATH=/bin:/usr/bin:/usr/local/bin:$PATH35export PATH36 37# Check if TMPDIR is set, default to /tmp38: ${TMPDIR:=/tmp}39 40#Securely create a temporary directory for the temporary files41TEMPDIR=$TMPDIR/gbug.$$42(umask 077 && mkdir "$TEMPDIR") || {43	echo "$0: could not create temporary directory" >&244	exit 145}46 47TEMPFILE1=$TEMPDIR/gbug148TEMPFILE2=$TEMPDIR/gbug249        50USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"51VERSTR="GNU gawkbug, version ${VERSION}"52 53do_help= do_version=54 55while [ $# -gt 0 ]56do57	case "$1" in58	--help)		shift ; do_help=y ;;59	--version)	shift ; do_version=y ;;60	--)		shift ; break ;;61	-*)		echo "gawkbug: ${1}: invalid option" >&262			echo "$USAGE" >&263			exit 2 ;;64	*)		break ;;65	esac66done67 68if [ -n "$do_version" ]69then70	echo "${VERSTR}"71	exit 072fi73 74if [ -n "$do_help" ]75then76	echo "${VERSTR}"77	echo "${USAGE}"78	echo79	cat << HERE_EOF80Gawkbug is used to send mail to the Gawk maintainers81for when Gawk doesn't behave like you'd like, or expect.82 83Gawkbug will start up your editor (as defined by the shell's84EDITOR environment variable) with a preformatted bug report85template for you to fill in. The report will be mailed to the86bug-gawk mailing list by default.87 88Please see https://www.gnu.org/software/gawk/manual/html_node/Bugs.html89for bug reporting instructions.  Reading that information before90repoting a bug will make everyones' lives easier.91 92If you invoke gawkbug by accident, just quit your editor without93saving any changes to the template, and no bug report will be sent.94HERE_EOF95	exit 096fi97 98# Figure out how to echo a string without a trailing newline99N=`echo 'hi there\c'`100case "$N" in101*c)	n=-n c= ;;102*)	n= c='\c' ;;103esac104 105BUGGAWK=bug-gawk@gnu.org106 107BUGADDR="${1-$BUGGAWK}"108 109if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]110then111	if [ -x /usr/bin/editor ]112	then113		DEFEDITOR=editor114	elif [ -x /usr/bin/vim ]115	then116		DEFEDITOR=vim117	elif [ -x /usr/bin/gvim ]118	then119		DEFEDITOR=gvim120	elif [ -x /usr/local/bin/ce ]121	then122		DEFEDITOR=ce123	elif [ -x /usr/local/bin/emacs ]124	then125		DEFEDITOR=emacs126	elif [ -x /usr/contrib/bin/emacs ]127	then128		DEFEDITOR=emacs129	elif [ -x /usr/bin/emacs ]130	then131		DEFEDITOR=emacs132	elif [ -x /usr/bin/xemacs ]133	then134		DEFEDITOR=xemacs135	elif [ -x /usr/bin/nano ]136	then137		DEFEDITOR=nano138	elif [ -x /usr/contrib/bin/jove ]139	then140		DEFEDITOR=jove141	elif [ -x /usr/local/bin/jove ]142	then143		DEFEDITOR=jove144	elif [ -x /usr/bin/vi ]145	then146		DEFEDITOR=vi147	else148		echo "$0: No default editor found: attempting to use vi" >&2149		DEFEDITOR=vi150	fi151fi152 153 154: ${EDITOR=$DEFEDITOR}155 156: ${USER=${LOGNAME-`whoami`}}157 158trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15159trap 'rm -rf "$TEMPDIR"' 0160 161UN=162if (uname) >/dev/null 2>&1163then164	UN=`uname -a`165fi166 167if [ -f /usr/lib/sendmail ]168then169	RMAIL="/usr/lib/sendmail"170	SMARGS="-i -t"171elif [ -f /usr/sbin/sendmail ]172then173	RMAIL="/usr/sbin/sendmail"174	SMARGS="-i -t"175else176	RMAIL=rmail177	SMARGS="$BUGADDR"178fi179 180INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'181 182cat > "$TEMPFILE1" <<EOF183From: ${USER}184To: ${BUGADDR}185Subject: ${INITIAL_SUBJECT}186 187Configuration Information [Automatically generated, do not change]:188Machine: $MACHINE189OS: $OS190Compiler: $CC191Compilation CFLAGS: $CFLAGS192uname output: $UN193Machine Type: $MACHTYPE194 195Gawk Version: $VERSION196 197Attestation 1:198	I have read https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.199	Yes / No  [ Choose one. If "No", then why haven't you? ]200 201Attestation 2:202	I have not modified the sources before building gawk.203	True / False204	[ Choose one. If "False", then please explain what you did and why. ]205 206Description:207	[Detailed description of the problem, suggestion, or complaint.]208 209Repeat-By:210	[Describe the sequence of events that causes the problem to occur.]211 212Fix:213	[Description of how to fix the problem.  If you don't know a214	fix for the problem, don't include this section.]215EOF216 217cp "$TEMPFILE1" "$TEMPFILE2"218chmod u+w "$TEMPFILE1"219 220trap '' 2		# ignore interrupts while in editor221 222edstat=1223while [ $edstat -ne 0 ]224do225	$EDITOR "$TEMPFILE1"226	edstat=$?227 228	if [ $edstat -ne 0 ]229	then230		echo "$0: editor \`$EDITOR' exited with nonzero status."231		echo "$0: Perhaps it was interrupted."232		echo "$0: Type \`y' to give up, and lose your bug report;"233		echo "$0: type \`n' to re-enter the editor."234		echo $n "$0: Do you want to give up? $c"235 236		read ans237		case "$ans" in238		[Yy]*) exit 1 ;;239		esac240 241		continue242	fi243 244	# find the subject from the temp file and see if it's been changed245	CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ 	]*||' | sed 1q`246 247	case "$CURR_SUB" in248	"${INITIAL_SUBJECT}")249		echo250		echo "$0: You have not changed the subject from the default."251		echo "$0: Please use a more descriptive subject header."252		echo "$0: Type \`y' to give up, and lose your bug report;"253		echo "$0: type \`n' to re-enter the editor."254		echo $n "$0: Do you want to give up? $c"255 256		read ans257		case "$ans" in258		[Yy]*) exit 1 ;;259		esac260 261		echo "$0:  The editor will be restarted in five seconds."262		sleep 5263		edstat=1264		;;265	esac266 267done268 269trap 'rm -rf "$TEMPDIR"; exit 1' 2	# restore trap on SIGINT270 271if cmp -s "$TEMPFILE1" "$TEMPFILE2"272then273	echo "File not changed, no bug report submitted."274	exit275fi276 277echo $n "Send bug report to ${BUGADDR}? [y/n] $c"278read ans279case "$ans" in280[Nn]*)	exit 0 ;;281esac282 283${RMAIL} $SMARGS < "$TEMPFILE1" || {284	cat "$TEMPFILE1" >> $HOME/dead.gawkbug285	echo "$0: mail to ${BUGADDR} failed: report saved in $HOME/dead.gawkbug" >&2286	echo "$0: please send it manually to ${BUGADDR}" >&2287}288 289exit 0290 
codekingpro/portable-devtools · Team Ai