diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-09-21 22:05:52 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-09-21 22:05:52 +0000 |
commit | aa1ed281856ed207f1fc1f8a60ffcf32330c8fc2 (patch) | |
tree | f4fdc3b8c70f20e146eddf83ed81c05db71c005b /src/unlink.c | |
parent | 6c9dc0efd9f2e179625cf735de90cc1b8de26202 (diff) | |
download | coreutils-aa1ed281856ed207f1fc1f8a60ffcf32330c8fc2.tar.gz |
Reject unknown options.
Diffstat (limited to 'src/unlink.c')
-rw-r--r-- | src/unlink.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/unlink.c b/src/unlink.c index 079c169be..5806ec8b0 100644 --- a/src/unlink.c +++ b/src/unlink.c @@ -73,29 +73,23 @@ 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], "--")) - { - --argc; - ++argv; - } - - if (argc < 2) + if (argc < optind + 1) { error (0, 0, _("missing operand")); usage (EXIT_FAILURE); } - if (2 < argc) + if (optind + 1 < argc) { - error (0, 0, _("extra operand %s"), quote (argv[2])); + error (0, 0, _("extra operand %s"), quote (argv[optind + 1])); usage (EXIT_FAILURE); } - if (unlink (argv[1]) != 0) - error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (argv[1])); + if (unlink (argv[optind]) != 0) + error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (argv[optind])); exit (EXIT_SUCCESS); } |