Subject: Re: kern/30425: genassym usage failure (now with patch)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Geoff Wing <gcw@pobox.com>
List: netbsd-bugs
Date: 08/20/2005 10:00:04
The following reply was made to PR kern/30425; it has been noted by GNATS.

From: Geoff Wing <gcw@pobox.com>
To: NetBSD GNATS <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: kern/30425: genassym usage failure (now with patch)
Date: Sat, 20 Aug 2005 19:59:41 +1000

 The getopts builtin was in my 1991 POSIX draft.  The usage
 args=`getopt ....` should have been deprecated at least that long.
 Even given that this is a build tool, we should be able to expect
 anyone building us to have a /bin/sh able to handle this.
 
 /usr/sbin/etcupdate and /usr/sbin/ypinit could also be changed.
 Maybe also a note in getopt.1 ?
 
 Fix is something like (maybe spew out usage on bad args?):
 
 --- usr.bin/genassym/genassym.sh.~1~	2005-08-20 19:54:06.000000000 +1000
 +++ usr.bin/genassym/genassym.sh	2005-08-20 19:54:06.000000000 +1000
 @@ -42,25 +42,22 @@
  	echo "usage: ${progname} [-c | -f] -- compiler command" >&2
  }
  
 -args=`getopt cf $*`
 -if [ $? != 0 ]; then
 -	usage;
 -	exit 1;
 -fi
 -set -- $args
 -
 -for i; do
 +while getopts cf i
 +do
  	case "$i" in
 -	-c)
 +	c)
  		ccode=1
 -		shift;;
 -	-f)
 +		;;
 +	f)
  		fcode=1
 -		shift;;
 -	--)
 -		shift; break;;
 +		;;
  	esac
  done
 +shift `expr $OPTIND - 1`
 +if [ $# -eq 0 ]; then
 +	usage
 +	exit 1
 +fi
  
  # Deal with any leading environment settings..