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.sbin | |
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.sbin')
-rw-r--r-- | usr.sbin/eeprom/main.c | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/lprm/lprm.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c index 8777a98d98b..f12893403f5 100644 --- a/usr.sbin/eeprom/main.c +++ b/usr.sbin/eeprom/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.9 2002/06/14 04:21:54 art Exp $ */ +/* $OpenBSD: main.c,v 1.10 2002/12/08 16:50:07 millert Exp $ */ /* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */ /*- @@ -122,9 +122,9 @@ main(argc, argv) int ch, do_stdin = 0; char *cp, line[BUFSIZE]; #ifdef __sparc__ - char *optstring = "-cf:ivN:"; + char *optstring = "cf:ivN:-"; #else - char *optstring = "-cf:i"; + char *optstring = "cf:i-"; #endif /* __sparc__ */ while ((ch = getopt(argc, argv, optstring)) != -1) diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c index 0189767a996..fb3de97d42d 100644 --- a/usr.sbin/lpr/lprm/lprm.c +++ b/usr.sbin/lpr/lprm/lprm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lprm.c,v 1.12 2002/06/08 01:53:43 millert Exp $ */ +/* $OpenBSD: lprm.c,v 1.13 2002/12/08 16:50:07 millert Exp $ */ /* $$NetBSD: lprm.c,v 1.9 1999/08/16 03:12:32 simonb Exp $ */ /* @@ -45,7 +45,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: lprm.c,v 1.12 2002/06/08 01:53:43 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lprm.c,v 1.13 2002/12/08 16:50:07 millert Exp $"; #endif #endif /* not lint */ @@ -111,7 +111,7 @@ main(int argc, char **argv) fatal("Your name is too long"); strlcpy(luser, p->pw_name, sizeof(luser)); person = luser; - while ((ch = getopt(argc, argv, "-P:w:")) != -1) { + while ((ch = getopt(argc, argv, "P:w:-")) != -1) { switch (ch) { case '-': users = -1; |