bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/3] grep: add --warnings={always,never,auto}.


From: Paolo Bonzini
Subject: Re: [PATCH 1/3] grep: add --warnings={always,never,auto}.
Date: Tue, 31 Aug 2010 11:59:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5

On 08/31/2010 11:48 AM, Jim Meyering wrote:
I was wondering why you chose not to make grep exit with status 2
from the beginning.  There is no legitimate use for the type of
regular expression that would evoke this failure, so it is unfair
to compare grep's new warning with gcc's -Werror, which can be
triggered for valid and useful constructs.

Some of them are _extremely_ doubtful (-Wformat, for example). But they are not errors anyway.

In line with my personal preferences [if I make the mistake, I want to
find out as soon as possible], I think we should make grep work as
Paul suggests.  The value/risk ratio of such a change is unusually high,
since the likelihood of a valid use triggering an unwarranted failure
is so low, and the typo of omitting the outer [...] in e.g., "[[:lower:]]"
is so common.

I don't see what concern could make you object to this change.

Because even though we agree that the regex we warn about is (practically) always going to be semantically incorrect, there's no doubt that the regex are syntactically valid, and this is IMHO enough reason to not return an exit status of 2. Rewriting it as [[:lower:]] would be as good then (or as bad).

Second, if this was done, it should operate in the same way in sed, expr, awk, and all other GNU programs that deal with regexes. (And possibly in glibc too).

If you want to add --warn=error (which is a "superset" of --warn=always behavior), that's fine and I actually like the idea. But I think making it the default non-POSIXLY_CORRECT behavior is wrong. Honestly, if this happened I would regret having introduced the feature in the first place.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]