diff options
author | Sami Kerola <kerolasa@iki.fi> | 2019-04-15 21:17:50 +0100 |
---|---|---|
committer | Sami Kerola <kerolasa@iki.fi> | 2019-04-15 21:17:50 +0100 |
commit | 1d628d132d26c37185a2b480f0b0285579bb0a1b (patch) | |
tree | 663381d4c3caed2de8af4960bb7e284c6d2b2f04 | |
parent | fa012d4bef0bd6ecfee5626bb015665d911bbaff (diff) | |
download | iputils-1d628d132d26c37185a2b480f0b0285579bb0a1b.tar.gz |
ping: option -N help should output to stdout, and exit with 0
Before this change ping output to stderr and exits with 2 which is ok when
the handler is invoked on usage error, but -N help is not an error so these
should indicate success (stdout, 0 as mentioned).
Addresses: https://github.com/iputils/iputils/issues/176
Reported-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r-- | ping6_common.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ping6_common.c b/ping6_common.c index 8115106..f2b91d8 100644 --- a/ping6_common.c +++ b/ping6_common.c @@ -499,9 +499,10 @@ static int niquery_option_subject_name_handler(int index __attribute__((__unused } #endif -int niquery_option_help_handler(int index __attribute__((__unused__)), const char *arg __attribute__((__unused__))) +int niquery_option_help_handler(int index, const char *arg __attribute__((__unused__))) { - fprintf(stderr, _("ping -6 -N <nodeinfo opt>\n" + fprintf(index ? stdout : stderr, + _("ping -6 -N <nodeinfo opt>\n" "Help:\n" " help\n" "Query:\n" @@ -520,7 +521,7 @@ int niquery_option_help_handler(int index __attribute__((__unused__)), const cha " subject-name=name\n" " subject-fqdn=name\n" )); - exit(2); + index ? exit(0) : exit(2); } int niquery_option_handler(const char *opt_arg) |