Subject: bin/2505: /bin/sh and $OPTIND
To: None <gnats-bugs@NetBSD.ORG>
From: None <wolf@marco.de>
List: netbsd-bugs
Date: 06/03/1996 10:47:00
>Number:         2505
>Category:       bin
>Synopsis:       OPTIND set wrong
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun  3 05:20:01 1996
>Last-Modified:
>Originator:     Wolfgang Schludi
>Organization:
	marco GmbH, Dachau, Germany
>Release:        960530
>Environment:
System: NetBSD tabatha 1.1_ALPHA NetBSD 1.1_ALPHA (ROBIN) #0: Mon Nov 6 16:27:59 MET 1995 leo@robin:/usr/src/sys/arch/i386/compile/ROBIN i386
>Description:
	If getopts parses an option which requires an argument,
	OPTIND is incremented even if the argument is appended
	to the option (without space).
>How-To-Repeat:
	$ cat <<'EOT' >exam
		while getopts "dl:am?" option; do
			case "$option" in
			d)	DEBUG=true ;;
			l)	LANG=$OPTARG ;;
			a)	LAM=false ;;
			m)	LA=false ;;
			?)	exit 1 ;;
			esac
		done
		shift `expr $OPTIND - 1`
	EOT
	$ /bin/sh exam -l D
	$ /bin/sh exam -lD
	shift: can't shift that many
>Fix:
	
	ham mer net
>Audit-Trail:
>Unformatted: