Patchwork [1/2] ethtool: Show short message for syntax error

login
register
mail settings
Submitter Ben Hutchings
Date Nov. 27, 2008, 4:11 a.m.
Message ID <20081127041112.GK15344@decadentplace.org.uk>
Download mbox | patch
Permalink /patch/11100/
State Not Applicable
Headers show

Comments

Ben Hutchings - Nov. 27, 2008, 4:11 a.m.
In case of a syntax error it's likely to be more helpful to just say
that rather than showing the entire usage information, which is now
very long.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
This change has been in Debian for some years, made in response to
bug report http://bugs.debian.org/256249

Ben.
Jeff Garzik - March 6, 2009, 10:59 a.m.
Ben Hutchings wrote:
> In case of a syntax error it's likely to be more helpful to just say
> that rather than showing the entire usage information, which is now
> very long.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> This change has been in Debian for some years, made in response to
> bug report http://bugs.debian.org/256249

applied


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- ethtool-6+20080227.orig/ethtool.c
+++ ethtool-6+20080227/ethtool.c
@@ -196,15 +196,24 @@ 
 static void show_usage(int badarg)
 {
 	int i;
-	fprintf(stderr, PACKAGE " version " VERSION "\n");
-	fprintf(stderr,
+	if (badarg != 0) {
+		fprintf(stderr,
+			"ethtool: bad command line argument(s)\n"
+			"For more information run ethtool -h\n"
+		);
+	}
+	else {
+		/* ethtool -h */
+		fprintf(stdout, PACKAGE " version " VERSION "\n");
+		fprintf(stdout,
 		"Usage:\n"
 		"ethtool DEVNAME\tDisplay standard information about device\n");
-	for (i = 0; args[i].srt; i++) {
-		fprintf(stderr, "        ethtool %s|%s DEVNAME\t%s\n%s",
-			args[i].srt, args[i].lng,
-			args[i].help,
-			args[i].opthelp ? args[i].opthelp : "");
+		for (i = 0; args[i].srt; i++) {
+			fprintf(stdout, "        ethtool %s|%s DEVNAME\t%s\n%s",
+				args[i].srt, args[i].lng,
+				args[i].help,
+				args[i].opthelp ? args[i].opthelp : "");
+		}
 	}
 	exit(badarg);
 }