[BusyBox] bug system from the command line

Paul Fox pgf at brightstareng.com
Sat Jul 16 11:43:00 MDT 2005


 > 
 > ...The bug tracking system is _icky_.

here, try this.  it's not pretty, but it seems to work well enough.

paul

#!/bin/sh

usage()
{
    cat >&2 <<EOF
usage:
 busybug [-a] bug-id
      (use -a to fetch/view attachments)
 or busybug list
EOF
}

if [ "$1" = "-a" ]
then
    getattach=1
    shift
fi

if [ ! "$1" ]
then
    usage
    exit 1
fi

bugid=$1

dumpit()
{
    bug=$1
    shift
    elinks $* -dump http://bugs.busybox.net/view.php?id="$bug"
}

buglist()
{
    elinks -dump-width 500 \
    	-dump "http://bugs.busybox.net/print_all_bug_page.php" |
	sed  -e 's/\[[ [:digit:]]\+\]//g' |
	awk '
	    /\[BusyBox\]/ {
		if ($2 == "[BusyBox]")
			offs = 0;
		else
			offs = 1;
		if ($(5 + offs) != "resolved") {
	    			printf $1 "\t";
				for (i = 7+offs; i <= NF; i++)
					printf  $i " ";
				printf "\n";
			    }
	    }' | sort | less
}

if [ "$bugid" = "list" ]
then
    buglist
    exit
elif [ ! "$getattach" ]
then
    dumpit $bugid | less
    exit
fi

if [ "$getattach" ]
then
    # get the name of the attachment
    files=($(dumpit $bugid -dump-width 500 |
    	sed -n -e '/File Added/s/.*: //p'))

    i=1
    for f in ${files[@]}
    do
	echo "$i) $f"
	i=$((i+1))
    done

    read -p "which file? " n

    if ! expr $n : '[0-9][0-9]*' >/dev/null
    then
	echo digits, please >&2
	exit 1
    fi

    file=${files[$((n-1))]}

    # get the index of the url of the attachment
    urlindex=$(dumpit $bugid -dump-width 500 |
    	sed -n -e 's/.*\[\([[:digit:]]\+\)\]'$file'.*/\1/p')
    # get the url
    url=$(dumpit $bugid | sed -n -e '/Visible links/,$p' |
    	sed -n -e 's/.*'$urlindex'.*\(http.*\)/\1/p')

    tmpfile=/tmp/busybug$$
    trap "rm -f $tmpfile" 0
    if wget -q -O - "$url"  >$tmpfile
    then
	read -n 1 -p "Fetched $file.  'd'isplay or 's'ave? " ans
	echo
	case $ans in
	d) 
	    less $tmpfile
	    ;;
	s) 
	    mv $tmpfile $file
	    ;;

	esac
    fi
fi
=---------------------
 paul fox, pgf at brightstareng.com


More information about the busybox mailing list