diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-08 16:50:08 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-08 16:50:08 +0000 |
commit | c5a38b6fdf1c2335f7f5558976e478f12d297990 (patch) | |
tree | a24f21bafd589dbe349a9eb8ce3651b05695577c /usr.bin | |
parent | 575d3fc4197705961dd3a1a91780df758087ebec (diff) |
GNU semantics say that if optstring begins with '-' then
each non-option shall be treated as arguments to option '\1'.
BSD getopt match '-' in optstring with a '-' on the command line.
This is used to support deprecated options like "su -" that would
otherwise prevent the use of getopt().
Resolving this simply requires that the leading '-' be moved somewhere
else (I moved it to the end of optstring) since position within
optstring is not meaningful.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/calendar/calendar.c | 6 | ||||
-rw-r--r-- | usr.bin/env/env.c | 6 | ||||
-rw-r--r-- | usr.bin/man/man.c | 6 | ||||
-rw-r--r-- | usr.bin/split/split.c | 6 | ||||
-rw-r--r-- | usr.bin/strings/strings.c | 6 | ||||
-rw-r--r-- | usr.bin/su/su.c | 6 | ||||
-rw-r--r-- | usr.bin/xstr/xstr.c | 6 |
7 files changed, 21 insertions, 21 deletions
diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 9ea6589bdd3..35a73f6a944 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.c,v 1.18 2002/06/23 03:07:21 deraadt Exp $ */ +/* $OpenBSD: calendar.c,v 1.19 2002/12/08 16:50:07 millert Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else -static char rcsid[] = "$OpenBSD: calendar.c,v 1.18 2002/06/23 03:07:21 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: calendar.c,v 1.19 2002/12/08 16:50:07 millert Exp $"; #endif #endif /* not lint */ @@ -92,7 +92,7 @@ main(argc, argv) (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "-abf:t:A:B:")) != -1) + while ((ch = getopt(argc, argv, "abf:t:A:B:-")) != -1) switch (ch) { case '-': /* backward contemptible */ case 'a': diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index 2f6fe09a0e6..eda66a36569 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: env.c,v 1.7 2002/02/16 21:27:45 millert Exp $ */ +/* $OpenBSD: env.c,v 1.8 2002/12/08 16:50:07 millert Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -41,7 +41,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";*/ -static char rcsid[] = "$OpenBSD: env.c,v 1.7 2002/02/16 21:27:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: env.c,v 1.8 2002/12/08 16:50:07 millert Exp $"; #endif /* not lint */ #include <err.h> @@ -66,7 +66,7 @@ main(argc, argv) setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "-i")) != -1) + while ((ch = getopt(argc, argv, "i-")) != -1) switch((char)ch) { case '-': /* obsolete */ case 'i': diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index bf77cb11b97..e4ffe0e03ca 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.22 2002/11/23 18:43:29 espie Exp $ */ +/* $OpenBSD: man.c,v 1.23 2002/12/08 16:50:07 millert Exp $ */ /* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -static char rcsid[] = "$OpenBSD: man.c,v 1.22 2002/11/23 18:43:29 espie Exp $"; +static char rcsid[] = "$OpenBSD: man.c,v 1.23 2002/12/08 16:50:07 millert Exp $"; #endif #endif /* not lint */ @@ -109,7 +109,7 @@ main(int argc, char *argv[]) machine = sflag = NULL; f_cat = f_how = 0; conffile = p_add = p_path = NULL; - while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1) + while ((ch = getopt(argc, argv, "aC:cfhkM:m:P:s:S:w-")) != -1) switch (ch) { case 'a': f_all = 1; diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index d052b919235..bc8be83fa95 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -1,4 +1,4 @@ -/* $OpenBSD: split.c,v 1.6 2002/02/16 21:27:53 millert Exp $ */ +/* $OpenBSD: split.c,v 1.7 2002/12/08 16:50:07 millert Exp $ */ /* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)split.c 8.3 (Berkeley) 4/25/94"; #else -static char rcsid[] = "$OpenBSD: split.c,v 1.6 2002/02/16 21:27:53 millert Exp $"; +static char rcsid[] = "$OpenBSD: split.c,v 1.7 2002/12/08 16:50:07 millert Exp $"; #endif #endif /* not lint */ @@ -85,7 +85,7 @@ main(argc, argv) int ch; char *ep, *p; - while ((ch = getopt(argc, argv, "-0123456789b:l:p:")) != -1) + while ((ch = getopt(argc, argv, "0123456789b:l:p:-")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': diff --git a/usr.bin/strings/strings.c b/usr.bin/strings/strings.c index 5ab6a58f6ff..89882bc1cd0 100644 --- a/usr.bin/strings/strings.c +++ b/usr.bin/strings/strings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strings.c,v 1.8 2002/09/23 04:10:14 millert Exp $ */ +/* $OpenBSD: strings.c,v 1.9 2002/12/08 16:50:07 millert Exp $ */ /* $NetBSD: strings.c,v 1.7 1995/02/15 15:49:19 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)strings.c 8.2 (Berkeley) 1/28/94"; #endif -static char rcsid[] = "$OpenBSD: strings.c,v 1.8 2002/09/23 04:10:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: strings.c,v 1.9 2002/12/08 16:50:07 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -103,7 +103,7 @@ main(argc, argv) offset_format = NULL; minlen = -1; maxlen = -1; - while ((ch = getopt(argc, argv, "-0123456789an:m:oft:")) != -1) + while ((ch = getopt(argc, argv, "0123456789an:m:oft:-")) != -1) switch((char)ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 9559ca769a9..ea0b1b6dd1a 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -1,4 +1,4 @@ -/* $OpenBSD: su.c,v 1.49 2002/12/07 22:54:13 millert Exp $ */ +/* $OpenBSD: su.c,v 1.50 2002/12/08 16:50:07 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91"; #else -static const char rcsid[] = "$OpenBSD: su.c,v 1.49 2002/12/07 22:54:13 millert Exp $"; +static const char rcsid[] = "$OpenBSD: su.c,v 1.50 2002/12/08 16:50:07 millert Exp $"; #endif #endif /* not lint */ @@ -89,7 +89,7 @@ main(int argc, char **argv) login_cap_t *lc; uid_t ruid; - while ((ch = getopt(argc, argv, "-a:c:fKLlm")) != -1) + while ((ch = getopt(argc, argv, "a:c:fKLlm-")) != -1) switch (ch) { case 'a': if (style) diff --git a/usr.bin/xstr/xstr.c b/usr.bin/xstr/xstr.c index b51a67e9592..896b13ae3df 100644 --- a/usr.bin/xstr/xstr.c +++ b/usr.bin/xstr/xstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xstr.c,v 1.9 2002/02/24 02:25:48 deraadt Exp $ */ +/* $OpenBSD: xstr.c,v 1.10 2002/12/08 16:50:07 millert Exp $ */ /* $NetBSD: xstr.c,v 1.5 1994/12/24 16:57:59 cgd Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)xstr.c 8.1 (Berkeley) 6/9/93"; #endif -static char rcsid[] = "$OpenBSD: xstr.c,v 1.9 2002/02/24 02:25:48 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: xstr.c,v 1.10 2002/12/08 16:50:07 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -103,7 +103,7 @@ main(int argc, char *argv[]) int c; int fdesc; - while ((c = getopt(argc, argv, "-cvl:")) != -1) + while ((c = getopt(argc, argv, "cvl:-")) != -1) switch (c) { case '-': readstd++; |