From patchwork Mon Aug 24 09:17:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Schurig X-Patchwork-Id: 43593 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7O9I33F007971 for ; Mon, 24 Aug 2009 09:18:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751955AbZHXJSA (ORCPT ); Mon, 24 Aug 2009 05:18:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751898AbZHXJR7 (ORCPT ); Mon, 24 Aug 2009 05:17:59 -0400 Received: from mx51.mymxserver.com ([85.199.173.110]:49369 "EHLO mx51.mymxserver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbZHXJR7 (ORCPT ); Mon, 24 Aug 2009 05:17:59 -0400 Received: from localhost (localhost [127.0.0.1]) by localhost.mx51.mymxserver.com (Postfix) with ESMTP id 01448148014; Mon, 24 Aug 2009 11:18:00 +0200 (CEST) X-Virus-Scanned: by Mittwald Mailscanner Received: from mx51.mymxserver.com ([127.0.0.1]) by localhost (mx51.mymxserver.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xj7d2UNm6S9x; Mon, 24 Aug 2009 11:17:59 +0200 (CEST) Received: from lin01.mn-solutions.de (pD95FA421.dip0.t-ipconnect.de [217.95.164.33]) by mx51.mymxserver.com (Postfix) with ESMTP id 74B98148010; Mon, 24 Aug 2009 11:17:59 +0200 (CEST) Received: by lin01.mn-solutions.de (Postfix, from userid 116) id DF96E1E0050; Mon, 24 Aug 2009 11:17:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.1.7-deb3 (2006-10-05) on lin01.mn-logistik.de X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.7-deb3 Received: from mnz66.mn-solutions.de (mnz66.mn-solutions.de [192.168.233.66]) by lin01.mn-solutions.de (Postfix) with ESMTP id ABC511E0036; Mon, 24 Aug 2009 11:17:49 +0200 (CEST) From: Holger Schurig To: Johannes Berg Subject: [IW] don't emit usage to stderr Date: Mon, 24 Aug 2009 11:17:19 +0200 User-Agent: KMail/1.9.7 Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200908241117.19840.hs4233@mail.mn-solutions.de> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Only write error output to stderr, not help und usage information. This allows now ./iw | less Signed-off-by: Holger Schurig Index: iw/iw.c =================================================================== --- iw.orig/iw.c 2009-08-24 10:00:08.000000000 +0200 +++ iw/iw.c 2009-08-24 10:01:08.000000000 +0200 @@ -103,24 +103,24 @@ static void __usage_cmd(struct cmd *cmd, { const char *start, *lend, *end; - fprintf(stderr, "%s", indent); + printf("%s", indent); switch (cmd->idby) { case CIB_NONE: break; case CIB_PHY: - fprintf(stderr, "phy "); + printf("phy "); break; case CIB_NETDEV: - fprintf(stderr, "dev "); + printf("dev "); break; } if (cmd->section) - fprintf(stderr, "%s ", cmd->section); - fprintf(stderr, "%s", cmd->name); + printf("%s ", cmd->section); + printf("%s", cmd->name); if (cmd->args) - fprintf(stderr, " %s", cmd->args); - fprintf(stderr, "\n"); + printf(" %s", cmd->args); + printf("\n"); if (!full || !cmd->help) return; @@ -129,7 +129,7 @@ static void __usage_cmd(struct cmd *cmd, if (strlen(indent)) indent = "\t\t"; else - fprintf(stderr, "\n"); + printf("\n"); /* print line by line */ start = cmd->help; @@ -138,18 +138,18 @@ static void __usage_cmd(struct cmd *cmd, lend = strchr(start, '\n'); if (!lend) lend = end; - fprintf(stderr, "%s", indent); - fprintf(stderr, "%.*s\n", (int)(lend - start), start); + printf("%s", indent); + printf("%.*s\n", (int)(lend - start), start); start = lend + 1; } while (end != lend); - fprintf(stderr, "\n"); + printf("\n"); } static void usage_options(void) { - fprintf(stderr, "Options:\n"); - fprintf(stderr, "\t--debug\t\tenable netlink debugging\n"); + printf("Options:\n"); + printf("\t--debug\t\tenable netlink debugging\n"); } static const char *argv0; @@ -158,17 +158,17 @@ static void usage(bool full) { struct cmd *cmd; - fprintf(stderr, "Usage:\t%s [options] command\n", argv0); + printf("Usage:\t%s [options] command\n", argv0); usage_options(); - fprintf(stderr, "\t--version\tshow version (%s)\n", iw_version); - fprintf(stderr, "Commands:\n"); + printf("\t--version\tshow version (%s)\n", iw_version); + printf("Commands:\n"); for (cmd = &__start___cmd; cmd < &__stop___cmd; cmd = (struct cmd *)((char *)cmd + cmd_size)) { if (!cmd->handler || cmd->hidden) continue; __usage_cmd(cmd, "\t", full); } - fprintf(stderr, "\nYou can omit the 'phy' or 'dev' if " + printf("\nYou can omit the 'phy' or 'dev' if " "the identification is unique,\n" "e.g. \"iw wlan0 info\" or \"iw phy0 info\". " "(Don't when scripting.)\n\n" @@ -188,7 +188,7 @@ TOPLEVEL(help, NULL, 0, 0, CIB_NONE, pri static void usage_cmd(struct cmd *cmd) { - fprintf(stderr, "Usage:\t%s [options] ", argv0); + printf("Usage:\t%s [options] ", argv0); __usage_cmd(cmd, "", true); usage_options(); }