Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1247016 > unrolled thread
| Started by | Sriram Raghunathan <sriram.r@nokia.com> |
|---|---|
| First post | 2015-10-14 19:20 +0200 |
| Last post | 2015-10-15 09:30 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan <sriram.r@nokia.com> - 2015-10-14 19:20 +0200
Re: [PATCH 1/1] perf :redirection of usage strings to stdout Sriram Raghunathan <sriram.r@nokia.com> - 2015-10-15 09:30 +0200
| From | Sriram Raghunathan <sriram.r@nokia.com> |
|---|---|
| Date | 2015-10-14 19:20 +0200 |
| Subject | [PATCH 1/1] perf :redirection of usage strings to stdout |
| Message-ID | <qjxSz-58q-27@gated-at.bofh.it> |
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++) {
--
2.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Sriram Raghunathan <sriram.r@nokia.com> |
|---|---|
| Date | 2015-10-15 09:30 +0200 |
| Message-ID | <qjL97-7Ts-13@gated-at.bofh.it> |
| In reply to | #1247016 |
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++) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web