diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2004-09-21 22:01:50 +0000 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-09-21 22:01:50 +0000 |
| commit | 4fa016cbc9907ef9da5272c5dcfa76f8ade216f1 (patch) | |
| tree | 04e1e2f72b4a504957d92701df36c278df2f8a13 /src/hostid.c | |
| parent | Include <getopt.h>. (diff) | |
| download | coreutils-4fa016cbc9907ef9da5272c5dcfa76f8ade216f1.tar.gz coreutils-4fa016cbc9907ef9da5272c5dcfa76f8ade216f1.zip | |
Include <getopt.h>.
(main): Reject unknown options.
Diffstat (limited to 'src/hostid.c')
| -rw-r--r-- | src/hostid.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/hostid.c b/src/hostid.c index 1ca34bb89..8bb76abf1 100644 --- a/src/hostid.c +++ b/src/hostid.c @@ -20,6 +20,7 @@ /* Written by Jim Meyering. */ #include <config.h> +#include <getopt.h> #include <stdio.h> #include <sys/types.h> @@ -73,18 +74,12 @@ 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 (optind < argc) { - --argc; - ++argv; - } - - if (argc > 1) - { - error (0, 0, _("extra operand %s"), quote (argv[1])); + error (0, 0, _("extra operand %s"), quote (argv[optind])); usage (EXIT_FAILURE); } |
