Date: Tue, 14 Dec 2010 20:35:08 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r216447 - head/usr.bin/printf Message-ID: <201012142035.oBEKZ8L9029868@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Tue Dec 14 20:35:08 2010 New Revision: 216447 URL: http://svn.freebsd.org/changeset/base/216447 Log: 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. Modified: head/usr.bin/printf/printf.c Modified: head/usr.bin/printf/printf.c ============================================================================== --- head/usr.bin/printf/printf.c Tue Dec 14 20:19:41 2010 (r216446) +++ head/usr.bin/printf/printf.c Tue Dec 14 20:35:08 2010 (r216447) @@ -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();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012142035.oBEKZ8L9029868>