NetBSD Problem Report #6762
Received: (qmail 24415 invoked from network); 8 Jan 1999 01:45:36 -0000
Message-Id: <199901080142.MAA03688@zen.quick.com.au>
Date: Fri, 8 Jan 1999 12:42:55 +1100 (EST)
From: "Simon J. Gerraty" <sjg@quick.com.au>
Reply-To: sjg@quick.com.au
To: gnats-bugs@gnats.netbsd.org
Subject: getopt(3) matches "--foo" as "--"
X-Send-Pr-Version: 3.95
>Number: 6762
>Category: lib
>Synopsis: getopt(3) matches "--foo" as "--"
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 07 17:50:00 +0000 1999
>Closed-Date: Sat Jan 09 20:35:21 +0000 1999
>Last-Modified: Sat Jan 09 20:36:00 +0000 1999
>Originator: Simon J. Gerraty
>Release: 19981229
>Organization:
Zen Programming...
>Environment:
System: NetBSD zen.quick.com.au 1.3.2 NetBSD 1.3.2 (ZEN-PUC) #2: Sun Oct 18 18:37:34 EST 1998 sjg@zen.quick.com.au:/u3/NetBSD/1.3.2/src/sys/arch/i386/compile/ZEN-PUC i386
>Description:
NetBSD's getopt(3) treats --foo the same as --
Eg:
$ getopt "vp:-:" -v -p one --unlink a n c
-v -p one -- a n c
This is compatible with the behaviour on SunOS 4.X, but SunOS 5.X
does the right thing:
: sjg:54; uname -a
SunOS frodo 4.1.4 2 sun4m
: sjg:55; getopt "vp:-:" -v -p one --unlink a n c
-v -p one -- a n c
: sjg:2; uname -a
SunOS zen.cdn.telstra.com.au 5.6 Generic_105181-06 sun4u sparc SUNW,Ultra-60
: sjg:3; getopt "vp:-:" -v -p one --unlink a n c
-v -p one -- unlink -- a n c
: sjg:4; getopt "vp:-:" -v -p one -- --unlink a n c
-v -p one -- --unlink a n c
Not tossing the chars after "--" allows progams to support options like
--unlink without having to resort to GNU's getopt.
>How-To-Repeat:
>Fix:
*** src/lib/libc/stdlib/getopt.c.old Tue Feb 3 23:49:31 1998
--- src/lib/libc/stdlib/getopt.c Fri Jan 8 12:22:08 1999
***************
*** 82,88 ****
place = EMSG;
return (-1);
}
! if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
--- 76,83 ----
place = EMSG;
return (-1);
}
! if (place[1] && *++place == '-' /* found "--" */
! && !place[1]) { /* and not "--foo" */
++optind;
place = EMSG;
return (-1);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: kleink
State-Changed-When: Sat Jan 9 12:35:21 PST 1999
State-Changed-Why:
Fixed, thanks. (This was also a POSIX compliance issue.)
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.