Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread Adam Borowski
On Mon, Jun 05, 2017 at 04:10:30PM -0700, Joe Perches wrote:
> On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> > The boolean --color argument did not offer the ability to force colourized
> > output even if stdout is not a terminal.
> 
> OK, but why is colorizing output not to terminals desired?

* You may post-process the output somehow.  grep, sed, some highlighter...
* The output may go to less -R, ansi2html, etc.

I've made a tool that does what you want, "pipetty" (Debian package
colorized-logs, in stretch and jessie-backports), but that's a dirty hack. 
Lying about isatty() works for programs that check STDOUT but it's notorious
to instead look at STDIN, which can't be fooled in a reliable way.  Thus,
it's better to standardize on --color={always,auto,never}.


Meow!
-- 
⢀⣴⠾⠻⢶⣦⠀ A tit a day keeps the vet away.
⣾⠁⢰⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ (Rejoice as my small-animal-murder-machine got unbroken after
⠈⠳⣄ nearly two years of no catch!)


Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread Adam Borowski
On Mon, Jun 05, 2017 at 04:10:30PM -0700, Joe Perches wrote:
> On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> > The boolean --color argument did not offer the ability to force colourized
> > output even if stdout is not a terminal.
> 
> OK, but why is colorizing output not to terminals desired?

* You may post-process the output somehow.  grep, sed, some highlighter...
* The output may go to less -R, ansi2html, etc.

I've made a tool that does what you want, "pipetty" (Debian package
colorized-logs, in stretch and jessie-backports), but that's a dirty hack. 
Lying about isatty() works for programs that check STDOUT but it's notorious
to instead look at STDIN, which can't be fooled in a reliable way.  Thus,
it's better to standardize on --color={always,auto,never}.


Meow!
-- 
⢀⣴⠾⠻⢶⣦⠀ A tit a day keeps the vet away.
⣾⠁⢰⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ (Rejoice as my small-animal-murder-machine got unbroken after
⠈⠳⣄ nearly two years of no catch!)


Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread John Brooks
On Mon, Jun 05, 2017 at 04:10:30PM -0700, Joe Perches wrote:
> On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> > The boolean --color argument did not offer the ability to force colourized
> > output even if stdout is not a terminal.
> 
> OK, but why is colorizing output not to terminals desired?

For example, to retain coloured output when using a pager (such as less -R).
Which is convenient for viewing/searching lengthy output from larger patch
sets, or when one is using something that interferes with the ability to scroll
such as screen, tmux, or mosh.

> 
> > Change the format of the argument
> > to the familiar --color[=WHEN] construct as seen in common Linux utilities
> > such as ls and dmesg, which allows the user to specify whether to colourize
> > output always, never, or only when the output is a terminal ("auto").
> > 
> > Because the option is no longer boolean, --nocolor (or --no-color) is no
> > longer available. Users of the old negative option should use --color=never
> > instead.
> 
> In general, I don't mind, but perhaps this option name
> could/should change.
> 
> As is, this also causes a previous command line that worked
> with --color to fail
> 
> $ ./scripts/checkpatch.pl --color foo.patch
> Invalid color mode: foo.patch
> 

Oh, that's pretty bad. I should have thought of that, sorry. I'll see what I
can do to stop it from eating other arguments.

--
John Brooks


Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread John Brooks
On Mon, Jun 05, 2017 at 04:10:30PM -0700, Joe Perches wrote:
> On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> > The boolean --color argument did not offer the ability to force colourized
> > output even if stdout is not a terminal.
> 
> OK, but why is colorizing output not to terminals desired?

For example, to retain coloured output when using a pager (such as less -R).
Which is convenient for viewing/searching lengthy output from larger patch
sets, or when one is using something that interferes with the ability to scroll
such as screen, tmux, or mosh.

> 
> > Change the format of the argument
> > to the familiar --color[=WHEN] construct as seen in common Linux utilities
> > such as ls and dmesg, which allows the user to specify whether to colourize
> > output always, never, or only when the output is a terminal ("auto").
> > 
> > Because the option is no longer boolean, --nocolor (or --no-color) is no
> > longer available. Users of the old negative option should use --color=never
> > instead.
> 
> In general, I don't mind, but perhaps this option name
> could/should change.
> 
> As is, this also causes a previous command line that worked
> with --color to fail
> 
> $ ./scripts/checkpatch.pl --color foo.patch
> Invalid color mode: foo.patch
> 

Oh, that's pretty bad. I should have thought of that, sorry. I'll see what I
can do to stop it from eating other arguments.

--
John Brooks


Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread Joe Perches
On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> The boolean --color argument did not offer the ability to force colourized
> output even if stdout is not a terminal.

OK, but why is colorizing output not to terminals desired?

> Change the format of the argument
> to the familiar --color[=WHEN] construct as seen in common Linux utilities
> such as ls and dmesg, which allows the user to specify whether to colourize
> output always, never, or only when the output is a terminal ("auto").
> 
> Because the option is no longer boolean, --nocolor (or --no-color) is no
> longer available. Users of the old negative option should use --color=never
> instead.

In general, I don't mind, but perhaps this option name
could/should change.

As is, this also causes a previous command line that worked
with --color to fail

$ ./scripts/checkpatch.pl --color foo.patch
Invalid color mode: foo.patch



Re: [PATCH] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-05 Thread Joe Perches
On Mon, 2017-06-05 at 18:27 -0400, John Brooks wrote:
> The boolean --color argument did not offer the ability to force colourized
> output even if stdout is not a terminal.

OK, but why is colorizing output not to terminals desired?

> Change the format of the argument
> to the familiar --color[=WHEN] construct as seen in common Linux utilities
> such as ls and dmesg, which allows the user to specify whether to colourize
> output always, never, or only when the output is a terminal ("auto").
> 
> Because the option is no longer boolean, --nocolor (or --no-color) is no
> longer available. Users of the old negative option should use --color=never
> instead.

In general, I don't mind, but perhaps this option name
could/should change.

As is, this also causes a previous command line that worked
with --color to fail

$ ./scripts/checkpatch.pl --color foo.patch
Invalid color mode: foo.patch