summaryrefslogtreecommitdiff
path: root/usr.bin/printf
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2010-12-14 01:16:56 +0000
committerXin LI <delphij@FreeBSD.org>2010-12-14 01:16:56 +0000
commit02a4a3f56c6722998e251e107ec1bd7c1aa432f3 (patch)
tree736339ec88fccc87803f5fdf1eb66a9f68ab31fa /usr.bin/printf
parent6715165066f1139e80bae62d93b2d7738295e484 (diff)
Notes
Diffstat (limited to 'usr.bin/printf')
-rw-r--r--usr.bin/printf/printf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 03e0dee5c29a..115185573f48 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -102,7 +102,7 @@ int
main(int argc, char *argv[])
{
size_t len;
- int ch, chopped, end, rval;
+ int chopped, end, rval;
char *format, *fmt, *start;
#ifndef SHELL
@@ -111,15 +111,15 @@ main(int argc, char *argv[])
#ifdef SHELL
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
#endif
- while ((ch = getopt(argc, argv, "")) != -1)
- switch (ch) {
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- argc -= optind;
- argv += optind;
+ /* Skip argv[0] which is the process name */
+ argv++;
+ argc--;
+
+ /* Need to accept/ignore "--" option. */
+ if (argc >= 1 && strcmp(*argv, "--") == 0) {
+ argc--;
+ argv++;
+ }
if (argc < 1) {
usage();