summaryrefslogtreecommitdiff
path: root/src/yes.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-09-21 22:05:52 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-09-21 22:05:52 +0000
commitaa1ed281856ed207f1fc1f8a60ffcf32330c8fc2 (patch)
treef4fdc3b8c70f20e146eddf83ed81c05db71c005b /src/yes.c
parent6c9dc0efd9f2e179625cf735de90cc1b8de26202 (diff)
downloadcoreutils-aa1ed281856ed207f1fc1f8a60ffcf32330c8fc2.tar.xz
Reject unknown options.
Diffstat (limited to 'src/yes.c')
-rw-r--r--src/yes.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/yes.c b/src/yes.c
index 56b15f736..6d0068662 100644
--- a/src/yes.c
+++ b/src/yes.c
@@ -73,25 +73,19 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
+ if (getopt (argc, argv, "+") != -1)
+ usage (EXIT_FAILURE);
- /* The above handles --help and --version.
- Since there is no other invocation of getopt, handle `--' here. */
- if (1 < argc && STREQ (argv[1], "--"))
+ if (argc <= optind)
{
- --argc;
- ++argv;
- }
-
- if (argc == 1)
- {
- argv[1] = "y";
- argc = 2;
+ optind = argc;
+ argv[argc++] = "y";
}
for (;;)
{
int i;
- for (i = 1; i < argc; i++)
+ for (i = optind; i < argc; i++)
if (fputs (argv[i], stdout) == EOF
|| putchar (i == argc - 1 ? '\n' : ' ') == EOF)
{