diff options
author | delphij <delphij@FreeBSD.org> | 2010-12-14 20:35:08 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2010-12-14 20:35:08 +0000 |
commit | 18ea61230f94e03736d9eb3bf3282631c755ff96 (patch) | |
tree | 1624c11e21506fff9110d0eeed483a3d39d068a5 /usr.bin/printf | |
parent | 879b3da6b59546ff4f89076a858a746027da0a05 (diff) | |
download | FreeBSD-src-18ea61230f94e03736d9eb3bf3282631c755ff96.zip FreeBSD-src-18ea61230f94e03736d9eb3bf3282631c755ff96.tar.gz |
Revert r216423 per request from Jilles.
The new behavior prevents us from being able to bail out explicitly
on unknown options that we have not implemented. BASH for instance
have introduced a '-v' for printf(1) builtin and it seems to be bad
to pretend that we supported it and have a script break silently.
Diffstat (limited to 'usr.bin/printf')
-rw-r--r-- | usr.bin/printf/printf.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index e646f5d..ef8111f 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) { size_t len; - int chopped, end, rval; + int ch, chopped, end, rval; char *format, *fmt, *start; #ifndef SHELL @@ -110,15 +110,15 @@ main(int argc, char *argv[]) #ifdef SHELL optreset = 1; optind = 1; opterr = 0; /* initialize getopt */ #endif - /* Skip argv[0] which is the process name */ - argv++; - argc--; - - /* Need to accept/ignore "--" option. */ - if (argc >= 1 && strcmp(*argv, "--") == 0) { - argc--; - argv++; - } + while ((ch = getopt(argc, argv, "")) != -1) + switch (ch) { + case '?': + default: + usage(); + return (1); + } + argc -= optind; + argv += optind; if (argc < 1) { usage(); |