Subject: bin/3358: example in getopt(1) wrong (sh-bug?)
To: None <gnats-bugs@gnats.netbsd.org>
From: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
List: netbsd-bugs
Date: 03/18/1997 01:04:49
>Number:         3358
>Category:       bin
>Synopsis:       example in getopt(1) wrong (sh-bug?)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 18 18:05:01 1997
>Last-Modified:
>Originator:     Hubert Feyrer
>Organization:
Hubert Feyrer <hubert.feyrer@rz.uni-regensburg.de>
>Release:        1.2
>Environment:
	
System: NetBSD miyu 1.2 NetBSD 1.2 (MIYU) #53: Wed Feb 26 18:21:38 GMT 1997 feyrer@miyu:/usr/src12/sys/arch/i386/compile/MIYU i386


>Description:
	The example in getopt(1) does not work, because 
	"set -- ... `getopt ...`" doesn't set $? to the return
	code of the getopt command but rather to 0, probably 
	the return code of the set-command.

	This seems to be some strange feature of /bin/sh. :)

	
>How-To-Repeat:
	$ getopt ab: -b ; echo $?
	getopt: option requires an argument -- b
 	--
	1
	$ set -- `getopt ab: -b` ; echo $?
	getopt: option requires an argument -- b
	0

	$ getopt ab: -x ; echo $?
	getopt: illegal option -- x
 	--
	1
	$ set -- `getopt ab: -x` ; echo $?
	getopt: illegal option -- x
	0


>Fix:
	unknown.
>Audit-Trail:
>Unformatted: