From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Molenda To: nobody@sourceware.cygnus.com Cc: gnats-prs@sourceware.cygnus.com Subject: Re: gnats/6: at-pr argument counting mangled Date: Mon, 25 Oct 1999 19:04:00 -0000 Message-id: <19991026020400.23575.qmail@sourceware.cygnus.com> X-SW-Source: 1999-q4/msg00010.html List-Id: The following reply was made to PR gnats/6; it has been noted by GNATS. From: Jason Molenda To: m.seaman@inpharmatica.co.uk Cc: gnats-gnats@sourceware.cygnus.com Subject: Re: gnats/6: at-pr argument counting mangled Date: Mon, 25 Oct 1999 18:55:37 -0700 Thanks for the PR and the patch. Your patch would not work for someone passing the -h command line parameter to at-pr.sh. Can you please try out the appended patch at your site and let me know if it works as expected? I ran through a few tests by hand, but I don't use timed notification locally. I'd like to have this tested out somewhere else before I commit it to the master gnats sources. Thanks! Jason Index: at-pr.sh =================================================================== RCS file: /cvs/gnats/gnats/gnats/at-pr.sh,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 at-pr.sh --- at-pr.sh 1998/11/05 19:54:09 1.1.1.1 +++ at-pr.sh 1999/10/26 01:52:59 @@ -20,7 +20,7 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. prog=`basename $0` -USAGE="$prog: [-h] [-d gnats_root] arguments +USAGE="Usage: $prog [-h] [-d gnats_root] arguments Arguments coming in are (all are required): @@ -31,20 +31,37 @@ USAGE="$prog: [-h] [-d gnats_root] argu 5 - full name of the submitter 6 - contact for the submitter 7 - address for GNATS_ADMIN - " PATH=/bin:/usr/bin; export PATH +if [ $# -eq 0 ] +then + echo "$USAGE" >&2 + exit 1 +fi + +if [ "$1" = "-h" -o "$1" = "--help" ] +then + echo "$USAGE" + exit 0 +fi + # process command line options -while [ $# -gt 0 ]; do +while [ $# -gt 7 ]; do case "$1" in -d | --directory) - if [ $# -eq 1 ]; then echo "value required for $1 option"; exit 1; fi - shift ; GNATS_ROOT="$1" ;; + if [ $# -eq 8 ] + then + echo "ERROR: value required for $1 option" >&2 + echo "$USAGE" >&2 + exit 1 + fi + shift + GNATS_ROOT="$1" ;; --directory=*) GNATS_ROOT="`echo $1 | sed 's/^[-a-z]*=//'`" ;; - -*) echo "$USAGE"; exit 1 ;; + -*) echo "$USAGE" >&2; exit 1 ;; esac shift done @@ -61,14 +78,14 @@ STATES_FILE=${GNATS_ROOT}/gnats-adm/stat [ -f ${GNATS_ROOT}/gnats-adm/config ] && . ${GNATS_ROOT}/gnats-adm/config if [ $# != 7 ]; then - echo "$prog: called with the incorrect number of arguments" - echo "$USAGE" + echo "ERROR: $prog called with the incorrect number of arguments" >&2 + echo "$USAGE" >&2 exit 1 fi if [ ! -d $GNATS_ROOT ]; then - echo "$prog: GNATS base directory $GNATS_ROOT does not exist." - echo "$USAGE" + echo "ERROR: $prog GNATS base directory $GNATS_ROOT does not exist." >&2 + echo "$USAGE" >&2 exit 1 fi