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/nohup.c | |
parent | 0d219ee57d8cab4a78432c97754e22dd9248951e (diff) | |
download | coreutils-4fa016cbc9907ef9da5272c5dcfa76f8ade216f1.tar.xz |
Include <getopt.h>.
(main): Reject unknown options.
Diffstat (limited to 'src/nohup.c')
-rw-r--r-- | src/nohup.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/nohup.c b/src/nohup.c index 96b2b2330..79a8c5043 100644 --- a/src/nohup.c +++ b/src/nohup.c @@ -18,6 +18,7 @@ /* Written by Jim Meyering */ #include <config.h> +#include <getopt.h> #include <stdio.h> #include <sys/types.h> #include <signal.h> @@ -86,16 +87,10 @@ 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. - Now, handle `--'. */ - if (argc > 1 && STREQ (argv[1], "--")) - { - --argc; - ++argv; - } - - if (argc <= 1) + if (argc <= optind) { error (0, 0, _("missing operand")); usage (NOHUP_FAILURE); @@ -168,7 +163,7 @@ main (int argc, char **argv) { int exit_status; int saved_errno; - char **cmd = argv + 1; + char **cmd = argv + optind; execvp (*cmd, cmd); exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); |