- edited description
[NetBSD-PR lib/6762] getopt(3) matches "--foo" as "--"
Issue #119
resolved
see following:
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=6762
this bug once had fixed, but currently have been broken by another [NetBSD-PR lib/17248]:
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=17248
Comments (4)
-
reporter -
reporter - edited description
-
reporter try following patch:
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index 976a06c..ffef548 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -77,11 +77,17 @@ getopt(int nargc, char * const nargv[], const char *ostr) return (-1); } optopt = *place++; - if (optopt == '-' && *place == 0) - /* "--" => end of options */ + if (optopt == '-') { ++optind; + if (*place == 0) + /* "--" => end of options */ + return (-1); + if (opterr) + (void)fprintf(stderr, + "%s: unrecognized option '--%s'\n", + getprogname(), place); place = EMSG; - return (-1); + return BADCH; } if (optopt == 0) { /* Solitary '-', treat as a '-' option
-
reporter - changed status to resolved
BUGFIX: Issue
#119-- [NetBSD-PR lib/6762] getopt(3) matches "--foo" as "--"→ <<cset 69a921fba286>>
- Log in to comment