diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-06-03 18:46:53 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-06-03 18:46:53 +0000 |
commit | accbe40d0762bc7853cc30c5d7dc8e45ebfb2d17 (patch) | |
tree | e70fd153e95949029fe3af810617e263d3bfd105 /lib | |
parent | 1dd14b875aae3a65f611fe324a07641db776b414 (diff) |
An optional argument cannot start with '-', even if permutation is
disabled. Magne Oestlyngen.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdlib/getopt_long.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c index 6079ce35030..bf50195b944 100644 --- a/lib/libc/stdlib/getopt_long.c +++ b/lib/libc/stdlib/getopt_long.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $ */ +/* $OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $ */ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /* @@ -57,7 +57,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $"; +static char *rcsid = "$OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <err.h> @@ -474,9 +474,10 @@ start: } else if (!(flags & FLAG_PERMUTE)) { /* * If permutation is disabled, we can accept an - * optional arg separated by whitespace. + * optional arg separated by whitespace so long + * as it does not start with a dash (-). */ - if (optind + 1 < nargc) + if (optind + 1 < nargc && *nargv[optind + 1] != '-') optarg = nargv[++optind]; } place = EMSG; |