From: Sriram Raghunathan <sriram.r@nokia.com>
To: Sriram Raghunathan <sriram.r@nokia.com>,
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
Date: Thu, 15 Oct 2015 12:52:46 +0530 [thread overview]
Message-ID: <561F5446.2090403@nokia.com> (raw)
In-Reply-To: <1444842607-26505-1-git-send-email-sriram.r@nokia.com>
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 <sriram.r@nokia.com>
> ---
> 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, "[=<n>]");
> + pos += fprintf(stdout, "[=<n>]");
> else
> - pos += fprintf(stderr, "[<n>]");
> + pos += fprintf(stdout, "[<n>]");
> else
> - pos += fprintf(stderr, " <n>");
> + pos += fprintf(stdout, " <n>");
> 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++) {
next prev parent reply other threads:[~2015-10-15 7:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1444282190-13605-1-git-send-email-sriram.r@nokia.com>
2015-10-13 14:57 ` [PATCH 1/1] perf:Adding --list-opts to usage string Arnaldo Carvalho de Melo
2015-10-13 15:24 ` Ramkumar Ramachandra
2015-10-14 2:29 ` Yunlong Song
2015-10-14 3:10 ` Arnaldo Carvalho de Melo
2015-10-14 3:42 ` Namhyung Kim
2015-10-14 13:31 ` Yunlong Song
[not found] ` <CA+JHD92p0QUJGrqKTMYD8FUKj5tS9MUV_njsvoFwaHhsQevn_Q@mail.gmail.com>
2015-10-14 17:10 ` [PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan
2015-10-15 7:22 ` Sriram Raghunathan [this message]
2015-10-15 7:11 ` [PATCH 1/1] perf:Adding --list-opts to usage string Yunlong Song
2015-10-14 13:44 ` [PATCH] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-15 7:39 ` [PATCH v2 0/3] perf help: Make perf's help consistent with other builtins Yunlong Song
2015-10-15 7:39 ` [PATCH v2 1/3] perf help: Add options description to 'perf -h' Yunlong Song
2015-10-19 15:29 ` Namhyung Kim
2015-10-20 2:13 ` Yunlong Song
2015-10-21 1:57 ` Namhyung Kim
2015-10-15 7:39 ` [PATCH v2 2/3] perf help: Change 'usage' to 'Usage' for consistency Yunlong Song
2015-10-20 7:48 ` [tip:perf/core] " tip-bot for Yunlong Song
2015-10-15 7:39 ` [PATCH v2 3/3] perf help: Change the usage's stdout to stderr " Yunlong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561F5446.2090403@nokia.com \
--to=sriram.r@nokia.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=artagnon@gmail.com \
--cc=dsahern@gmail.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=yunlong.song@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.