From c5a38b6fdf1c2335f7f5558976e478f12d297990 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 8 Dec 2002 16:50:08 +0000 Subject: 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. --- usr.bin/xstr/xstr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.bin/xstr/xstr.c') 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 @@ -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++; -- cgit v1.2.3