From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdFFUDr (ORCPT ); Tue, 6 Jun 2017 16:03:47 -0400 Received: from smtprelay0037.hostedemail.com ([216.40.44.37]:44920 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751239AbdFFUDq (ORCPT ); Tue, 6 Jun 2017 16:03:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1543:1593:1594:1605:1711:1730:1747:1777:1792:1801:2110:2198:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4605:5007:7875:7903:8957:9040:9121:10004:10400:10848:11232:11233:11658:11914:12043:12291:12555:12683:12740:12760:12895:13439:14181:14659:14721:14819:21080:21222:21324:21451:21627:30051:30054:30062:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: show08_3d4a7140bfc01 X-Filterd-Recvd-Size: 4526 Message-ID: <1496779410.1968.32.camel@perches.com> Subject: Re: [PATCH v2] checkpatch: Change format of --color argument to --color[=WHEN] From: Joe Perches To: John Brooks Cc: Andy Whitcroft , linux-kernel@vger.kernel.org, Andrew Morton Date: Tue, 06 Jun 2017 13:03:30 -0700 In-Reply-To: <20170606195652.GA17579@kitsune.fastquake.com> References: <1496704230.1968.5.camel@perches.com> <1496768832-31004-1-git-send-email-john@fastquake.com> <1496776882.1968.27.camel@perches.com> <20170606195652.GA17579@kitsune.fastquake.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-06-06 at 19:56 +0000, John Brooks wrote: > On Tue, Jun 06, 2017 at 12:21:22PM -0700, Joe Perches wrote: > > On Tue, 2017-06-06 at 13:07 -0400, John Brooks wrote: > > > The boolean --color argument did not offer the ability to force colourized > > > output even if stdout is not a terminal. 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. > > > > It is possible to add --nocolor and --no-color to the > > arguments for GetOptions to keep the old behavior intact. > > > > I think this works: > > --- > > scripts/checkpatch.pl | 35 +++++++++++++++++++++++++++++------ > > 1 file changed, 29 insertions(+), 6 deletions(-) > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > index 4b9569fa931b..372d541c2c46 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -56,7 +56,7 @@ my $codespell = 0; > > my $codespellfile = "/usr/share/codespell/dictionary.txt"; > > my $conststructsfile = "$D/const_structs.checkpatch"; > > my $typedefsfile = ""; > > -my $color = 1; > > +my $color = "auto"; > > my $allow_c99_comments = 1; > > > > sub help { > > @@ -115,7 +115,8 @@ Options: > > (default:/usr/share/codespell/dictionary.txt) > > --codespellfile Use this codespell dictionary > > --typedefsfile Read additional types from this file > > - --color Use colors when output is STDOUT (default: on) > > + --color[=WHEN] Use colors 'always', 'never', or only when output > > + is a terminal ('auto'). Default is 'auto'. > > -h, --help, --version display this help and exit > > > > When FILE is - read standard input. > > @@ -181,6 +182,14 @@ if (-f $conf) { > > unshift(@ARGV, @conf_args) if @conf_args; > > } > > > > +# Perl's Getopt::Long allows options to take optional arguments after a space. > > +# Prevent --color by itself from consuming other arguments > > +foreach (@ARGV) { > > + if ($_ eq "--color" || $_ eq "-color") { > > + $_ = "--color=$color"; > > + } > > +} > > + > > GetOptions( > > 'q|quiet+' => \$quiet, > > 'tree!' => \$tree, > > @@ -211,7 +220,9 @@ GetOptions( > > 'codespell!' => \$codespell, > > 'codespellfile=s' => \$codespellfile, > > 'typedefsfile=s' => \$typedefsfile, > > - 'color!' => \$color, > > + 'color=s' => \$color, > > + '-no-color!' => \$color, #keep old behaviors of -nocolor > > + '-nocolor!' => \$color, #keep old behaviors of -nocolor [] > Good changes overall. Does one want the leading dash and trailing bang here, > however? You're probably right about the trailing bang. > I don't know what the leading dash does (I would guess it makes it > store 0 into the variable? > I can't find anything in the perldoc) No idea. Me neither. > but the bang > makes the option negatable, which would allow you to do --nonocolor/ > --nono-color, and that may not make sense here. Right. The bang should be removed. When you submit a V3 with the appropriate changes, Acked-by: Joe Perches cheers, Joe