Bug 32126

Summary: getopt(3) not Unix-98 conformant
Product: Base System Reporter: Wilhelm B. Kloke <wb>
Component: standardsAssignee: freebsd-standards (Nobody) <standards>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-RELEASE   
Hardware: Any   
OS: Any   

Description Wilhelm B. Kloke 2001-11-20 09:20:01 UTC
	I have been hit by a non-conformance to Unix standard (whatever this
	may mean). FreeBSD uses a global optreset to re-initialize
	some internal data structure for getopt. This is not conformant to
	Unix 98 spec (see opengroup.org man page) nor to Linux usage.

Fix: 

I propose to silently dropping use of optreset, as the reset
	condition can normally be signaled via optind. No applications
	should be affected, anyway. Grep -F -R optreset shows that
	contrib/nvi crypto/heimdal/lib/roken crypto/kerberosIV/lib
	are coming with their own getopt.c. Other apps using optreset
	are bin/chio bin/sh sbin/camcontrol sbin/ipfw sbin/mount
	sys/boot/ usr.sbin/ancontrol usr.sbin/inetd usr.sbin/mlxcontrol
	usr.sbin/mptable usr.sbin/raycontrol usr.sbin/wicontrol
	
	Camcontrol may have a problem. There is a discussion in  the comments.
	Just let camcontrol have its own getopt.c.
Comment 1 Johan Karlsson freebsd_committer freebsd_triage 2002-08-21 21:40:04 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-standards

-standards hopefully know if optreset violates the 
standards we are trying to comform to and what to do 
about this.
Comment 2 Stefan Farfeleder freebsd_committer freebsd_triage 2004-09-14 16:56:07 UTC
State Changed
From-To: open->patched

The visibility of optreset was fixed in unistd.h's revision 1.50.
Comment 3 Stefan Farfeleder freebsd_committer freebsd_triage 2004-09-14 17:15:03 UTC
On Tue, Sep 14, 2004 at 04:02:09PM +0000, Stefan Farfeleder wrote:
> The visibility of optreset was fixed in unistd.h's revision 1.50.
                                                              ^^^^
Oops, I actually meant 1.51.
Comment 4 Stefan Farfeleder freebsd_committer freebsd_triage 2005-12-26 18:39:14 UTC
State Changed
From-To: patched->closed

The variable optreset is a extension to POSIX, it does not violate it.