diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-23 16:40:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-23 16:40:45 +0000 |
commit | 49ef61b214d2c1c164fa8ede893b9e0e73405f71 (patch) | |
tree | ea46e8a99b06e26a2054809b807e0271485d96d6 /usr.bin/printf | |
parent | 1294b4ef28fe59ca2c2b47c0bb88347578356cd1 (diff) |
Don't not use getopt() in printf(1) since it causes formats beginning
with a '-' to be interpreted as flags. Noticed by Alan Barrett.
There is really no reason for this to be a builtin in csh...
Diffstat (limited to 'usr.bin/printf')
-rw-r--r-- | usr.bin/printf/printf.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 8829effeb77..2ce53bb8e0e 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printf.c,v 1.10 2003/06/10 22:20:49 deraadt Exp $ */ +/* $OpenBSD: printf.c,v 1.11 2003/06/23 16:40:44 millert Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -39,7 +39,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)printf.c 5.9 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$OpenBSD: printf.c,v 1.10 2003/06/10 22:20:49 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: printf.c,v 1.11 2003/06/23 16:40:44 millert Exp $"; #endif /* not lint */ #include <ctype.h> @@ -120,23 +120,12 @@ main(int argc, char *argv[]) setlocale (LC_ALL, ""); #endif - while ((ch = getopt(argc, argv, "")) != -1) { - switch (ch) { - case '?': - default: - usage(); - return (1); - } - } - argc -= optind; - argv += optind; - - if (argc < 1) { + if (argc < 2) { usage(); return (1); } - format = *argv; + format = *++argv; gargv = ++argv; #define SKIP1 "#-+ 0" |