From 7870fa108121ddc3d4aa3ae252250040638a4f42 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 17 Jun 2004 13:09:21 +0000 Subject: [PATCH] (main): Handle "--". --- src/chroot.c | 9 +++++++++ src/hostid.c | 8 ++++++++ src/hostname.c | 8 ++++++++ src/pwd.c | 8 ++++++++ src/sync.c | 8 ++++++++ 5 files changed, 41 insertions(+) diff --git a/src/chroot.c b/src/chroot.c index 5a28e32c44..3d196af6eb 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -75,6 +75,15 @@ main (int argc, char **argv) parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); + + /* 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 <= 1) { error (0, 0, _("too few arguments")); diff --git a/src/hostid.c b/src/hostid.c index 095b758917..a262e78748 100644 --- a/src/hostid.c +++ b/src/hostid.c @@ -73,6 +73,14 @@ main (int argc, char **argv) parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); + /* 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 > 1) { error (0, 0, _("too many arguments")); diff --git a/src/hostname.c b/src/hostname.c index c9b62e446a..ff7b4e4cc0 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -97,6 +97,14 @@ main (int argc, char **argv) parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); + /* The above handles --help and --version. + Since there is no other invocation of getopt, handle `--' here. */ + if (1 < argc && STREQ (argv[1], "--")) + { + --argc; + ++argv; + } + #ifdef HAVE_SETHOSTNAME if (argc == 2) { diff --git a/src/pwd.c b/src/pwd.c index 4686892008..6c64be7404 100644 --- a/src/pwd.c +++ b/src/pwd.c @@ -306,6 +306,14 @@ main (int argc, char **argv) parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); + /* 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 (1 < argc) error (0, 0, _("ignoring non-option arguments")); diff --git a/src/sync.c b/src/sync.c index 7dbbc55669..045b820c24 100644 --- a/src/sync.c +++ b/src/sync.c @@ -67,6 +67,14 @@ main (int argc, char **argv) parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION, usage, AUTHORS, (char const *) NULL); + /* 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 (1 < argc) error (0, 0, _("ignoring all arguments")); -- 2.47.3