summaryrefslogtreecommitdiffstats
path: root/usr.bin/printf
diff options
context:
space:
mode:
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 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();
OpenPOWER on IntegriCloud