Skip to contentSkip to conversation

iproute: make ss --help output to stdout

PATCH In review Andreas Henriksson 2 participants 2 messages Dec 7, 2009 – Dec 26, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute: make ss --help output to stdout

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.)

misc/ss.c +17 -6
index ac7f411..8a9663c 100644
@@ -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();
 		}
#1 lore raw
Quoted 8 lines · On Mon, 7 Dec 2009 13:12:36 +0100 Andreas Henriksson <[email protected]> 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