* [PATCH] iproute: make ss --help output to stdout
@ 2009-12-07 12:12 Andreas Henriksson
2009-12-26 18:05 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Henriksson @ 2009-12-07 12:12 UTC (permalink / raw
To: shemminger; +Cc: netdev, 545008
Peter Palfrader said in http://bugs.debian.org/545008 that
"--help output, if explicitly requested, should go to stdout, not stderr."
which this patch fixes.
Additionally, the exit code was adjusted to success if help was
explicitly requested.
(Syntax error still outputs to stderr and has the same exit code.)
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
diff --git a/misc/ss.c b/misc/ss.c
index ac7f411..8a9663c 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2331,12 +2331,9 @@ int print_summary(void)
return 0;
}
-
-static void usage(void) __attribute__((noreturn));
-
-static void usage(void)
+static void _usage(FILE *dest)
{
- fprintf(stderr,
+ fprintf(dest,
"Usage: ss [ OPTIONS ]\n"
" ss [ OPTIONS ] [ FILTER ]\n"
" -h, --help this message\n"
@@ -2368,6 +2365,19 @@ static void usage(void)
" -F, --filter=FILE read filter information from FILE\n"
" FILTER := [ state TCP-STATE ] [ EXPRESSION ]\n"
);
+}
+
+static void help(void) __attribute__((noreturn));
+static void help(void)
+{
+ _usage(stdout);
+ exit(0);
+}
+
+static void usage(void) __attribute__((noreturn));
+static void usage(void)
+{
+ _usage(stderr);
exit(-1);
}
@@ -2514,7 +2524,7 @@ int main(int argc, char *argv[])
else if (strcmp(optarg, "netlink") == 0)
preferred_family = AF_NETLINK;
else if (strcmp(optarg, "help") == 0)
- usage();
+ help();
else {
fprintf(stderr, "ss: \"%s\" is invalid family\n", optarg);
usage();
@@ -2596,6 +2606,7 @@ int main(int argc, char *argv[])
exit(0);
case 'h':
case '?':
+ help();
default:
usage();
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iproute: make ss --help output to stdout
2009-12-07 12:12 [PATCH] iproute: make ss --help output to stdout Andreas Henriksson
@ 2009-12-26 18:05 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2009-12-26 18:05 UTC (permalink / raw
To: Andreas Henriksson; +Cc: netdev, 545008
On Mon, 7 Dec 2009 13:12:36 +0100
Andreas Henriksson <andreas@fatal.se> wrote:
> Peter Palfrader said in http://bugs.debian.org/545008 that
> "--help output, if explicitly requested, should go to stdout, not stderr."
> which this patch fixes.
>
> Additionally, the exit code was adjusted to success if help was
> explicitly requested.
>
> (Syntax error still outputs to stderr and has the same exit code.)
ok, applied
--
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-12-26 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-07 12:12 [PATCH] iproute: make ss --help output to stdout Andreas Henriksson
2009-12-26 18:05 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.