From 4ec0a795e52ca8effd622d8b3c49c6b927aceef5 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 27 Nov 2008 04:11:12 +0000 Subject: ethtool: Show short message for syntax error 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 Signed-off-by: Jeff Garzik --- ethtool.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ethtool.c b/ethtool.c index 7669180..1ec560d 100644 --- a/ethtool.c +++ b/ethtool.c @@ -197,15 +197,24 @@ static struct option { 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); } -- cgit v1.2.1