[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
timeout --help --help
From: |
Kim Hansen |
Subject: |
timeout --help --help |
Date: |
Sun, 21 Mar 2010 17:16:24 +0100 |
When testing the --kill-after I found the following strange behaviour:
address@hidden:~$ timeout --help --help
timeout: unrecognized option '--help'
Try `timeout --help' for more information.
address@hidden:~$
It looks like parse_long_options() only will give help or version if
that is the only option passed to the program, the following change
made the program behave like I expected it to do:
address@hidden:/tmp/coreutils/git/src$ git diff
diff --git a/src/timeout.c b/src/timeout.c
index 49fc4d8..3b00312 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -83,6 +83,8 @@ static struct option const long_options[] =
{
{"kill-after", required_argument, NULL, 'k'},
{"signal", required_argument, NULL, 's'},
+ {GETOPT_HELP_OPTION_DECL},
+ {GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
@@ -261,9 +263,6 @@ main (int argc, char **argv)
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
- usage, AUTHORS, (char const *) NULL);
-
while ((c = getopt_long (argc, argv, "+k:s:", long_options, NULL)) != -1)
{
switch (c)
@@ -271,11 +270,17 @@ main (int argc, char **argv)
case 'k':
kill_after = parse_duration (optarg);
break;
+
case 's':
term_signal = operand2sig (optarg, signame);
if (term_signal == -1)
usage (EXIT_CANCELED);
break;
+
+ case_GETOPT_HELP_CHAR;
+
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+
default:
usage (EXIT_CANCELED);
break;
address@hidden:/tmp/coreutils/git/src$
--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437
- timeout --help --help,
Kim Hansen <=