diff 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); } |