From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754570AbbJOHYz (ORCPT ); Thu, 15 Oct 2015 03:24:55 -0400 Received: from demumfd002.nsn-inter.net ([93.183.12.31]:55631 "EHLO demumfd002.nsn-inter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753263AbbJOHYx (ORCPT ); Thu, 15 Oct 2015 03:24:53 -0400 Message-ID: <561F5446.2090403@nokia.com> Date: Thu, 15 Oct 2015 12:52:46 +0530 From: Sriram Raghunathan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Sriram Raghunathan , a.p.zijlstra@chello.nl, paulus@samba.org, acme@kernel.org, yunlong.song@huawei.com CC: mingo@redhat.com, artagnon@gmail.com, hemant@linux.vnet.ibm.com, jolsa@kernel.org, dsahern@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] perf :redirection of usage strings to stdout References: <1444842607-26505-1-git-send-email-sriram.r@nokia.com> In-Reply-To: <1444842607-26505-1-git-send-email-sriram.r@nokia.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 5672 X-purgate-ID: 151667::1444893775-00005272-2408BE3D/0/0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry, I made a mistake please ignore this patch. Sriram On Wednesday 14 October 2015 10:40 PM, Sriram Raghunathan wrote: > This patch is to redirect the usage/builtin help strings > to stdout rather than stderr. This is follows the patter > similar to that of some of the coreutils (ls, rm). > > This patch originated from the discussion on a mail loop > about the inconsistency usage of stdout/stderr usage. > > Tested the piece of code below with > > # perf stat -h > /tmp/foo 2>> /tmp/bar > # perf --help > /tmp/foo 2>&1 /tmp/bar > > Signed-off-by: Sriram Raghunathan > --- > tools/perf/util/parse-options.c | 54 ++++++++++++++++++++--------------------- > 1 file changed, 27 insertions(+), 27 deletions(-) > > diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c > index 01626be..c81b2e3 100644 > --- a/tools/perf/util/parse-options.c > +++ b/tools/perf/util/parse-options.c > @@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full) > int pad; > > if (opts->type == OPTION_GROUP) { > - fputc('\n', stderr); > + fputc('\n', stdout); > if (*opts->help) > - fprintf(stderr, "%s\n", opts->help); > + fprintf(stdout, "%s\n", opts->help); > return; > } > if (!full && (opts->flags & PARSE_OPT_HIDDEN)) > @@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full) > if (opts->flags & PARSE_OPT_DISABLED) > return; > > - pos = fprintf(stderr, " "); > + pos = fprintf(stdout, " "); > if (opts->short_name) > - pos += fprintf(stderr, "-%c", opts->short_name); > + pos += fprintf(stdout, "-%c", opts->short_name); > else > - pos += fprintf(stderr, " "); > + pos += fprintf(stdout, " "); > > if (opts->long_name && opts->short_name) > - pos += fprintf(stderr, ", "); > + pos += fprintf(stdout, ", "); > if (opts->long_name) > - pos += fprintf(stderr, "--%s", opts->long_name); > + pos += fprintf(stdout, "--%s", opts->long_name); > > switch (opts->type) { > case OPTION_ARGUMENT: > @@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full) > case OPTION_UINTEGER: > if (opts->flags & PARSE_OPT_OPTARG) > if (opts->long_name) > - pos += fprintf(stderr, "[=]"); > + pos += fprintf(stdout, "[=]"); > else > - pos += fprintf(stderr, "[]"); > + pos += fprintf(stdout, "[]"); > else > - pos += fprintf(stderr, " "); > + pos += fprintf(stdout, " "); > break; > case OPTION_CALLBACK: > if (opts->flags & PARSE_OPT_NOARG) > @@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full) > if (opts->argh) { > if (opts->flags & PARSE_OPT_OPTARG) > if (opts->long_name) > - pos += fprintf(stderr, "[=<%s>]", opts->argh); > + pos += fprintf(stdout, "[=<%s>]", opts->argh); > else > - pos += fprintf(stderr, "[<%s>]", opts->argh); > + pos += fprintf(stdout, "[<%s>]", opts->argh); > else > - pos += fprintf(stderr, " <%s>", opts->argh); > + pos += fprintf(stdout, " <%s>", opts->argh); > } else { > if (opts->flags & PARSE_OPT_OPTARG) > if (opts->long_name) > - pos += fprintf(stderr, "[=...]"); > + pos += fprintf(stdout, "[=...]"); > else > - pos += fprintf(stderr, "[...]"); > + pos += fprintf(stdout, "[...]"); > else > - pos += fprintf(stderr, " ..."); > + pos += fprintf(stdout, " ..."); > } > break; > default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */ > @@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full) > if (pos <= USAGE_OPTS_WIDTH) > pad = USAGE_OPTS_WIDTH - pos; > else { > - fputc('\n', stderr); > + fputc('\n', stdout); > pad = USAGE_OPTS_WIDTH; > } > - fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help); > + fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help); > } > > int usage_with_options_internal(const char * const *usagestr, > @@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr, > if (!usagestr) > return PARSE_OPT_HELP; > > - fprintf(stderr, "\n usage: %s\n", *usagestr++); > + fprintf(stdout, "\n usage: %s\n", *usagestr++); > while (*usagestr && **usagestr) > - fprintf(stderr, " or: %s\n", *usagestr++); > + fprintf(stdout, " or: %s\n", *usagestr++); > while (*usagestr) { > - fprintf(stderr, "%s%s\n", > + fprintf(stdout, "%s%s\n", > **usagestr ? " " : "", > *usagestr); > usagestr++; > } > > if (opts->type != OPTION_GROUP) > - fputc('\n', stderr); > + fputc('\n', stdout); > > for ( ; opts->type != OPTION_END; opts++) > print_option_help(opts, full); > > - fputc('\n', stderr); > + fputc('\n', stdout); > > return PARSE_OPT_HELP; > } > @@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr, > if (!usagestr) > goto opt; > > - fprintf(stderr, "\n usage: %s\n", *usagestr++); > + fprintf(stdout, "\n usage: %s\n", *usagestr++); > while (*usagestr && **usagestr) > - fprintf(stderr, " or: %s\n", *usagestr++); > + fprintf(stdout, " or: %s\n", *usagestr++); > while (*usagestr) { > - fprintf(stderr, "%s%s\n", > + fprintf(stdout, "%s%s\n", > **usagestr ? " " : "", > *usagestr); > usagestr++; > } > - fputc('\n', stderr); > + fputc('\n', stdout); > > opt: > for ( ; opts->type != OPTION_END; opts++) {