summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2019-04-15 21:17:50 +0100
committerSami Kerola <kerolasa@iki.fi>2019-04-15 21:17:50 +0100
commit1d628d132d26c37185a2b480f0b0285579bb0a1b (patch)
tree663381d4c3caed2de8af4960bb7e284c6d2b2f04
parentfa012d4bef0bd6ecfee5626bb015665d911bbaff (diff)
downloadiputils-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.c7
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)