bug-grep
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] grep: diagnose and exit-2 for bogus REs like [:space:],


From: Paolo Bonzini
Subject: Re: [PATCH 1/2] grep: diagnose and exit-2 for bogus REs like [:space:], [:digit:], etc.
Date: Fri, 03 Sep 2010 10:19:41 +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 09/01/2010 07:09 PM, Jim Meyering wrote:
I've just tweaked the documentation and pushed this:

 From adf0bf94a10d40f39d72663878a245163232aae6 Mon Sep 17 00:00:00 2001
From: Jim Meyering<address@hidden>
Date: Tue, 31 Aug 2010 21:14:41 +0200
Subject: [PATCH 1/2] grep: diagnose and exit-2 for bogus REs like [:space:], 
[:digit:], etc.

When I make a mistake like this:
   grep '[:lower:]' ...
be it in a script or on the command line, I want to know about
it as soon as possible.  I don't want grep to print a mere warning
that it is interpreting this suspicious and almost guaranteed-wrong
regular expression as a set of just 6 bytes.  And I certainly don't
want grep to silently do the wrong thing, even if that would be
officially standards-conforming.  It's obvious that I intended
[[:lower:]], and I want my error to be diagnosed in a way that is
most likely to get my attention.  Thus, with this change, grep now
prints a diagnostic and exits with status 2 the moment it
encounters an offending [:char_class:] construct.

This changes the way grep works by default, rather than
putting this new behavior on an option.  A new option
would seldom be used in scripts (not portable), and would
probably be used only rarely by those who need it the most.
This new functionality provides a valuable safety measure
and incurs truly negligible risk.

For strict POSIX compliance, set POSIXLY_CORRECT in
your environment.  That disables this new feature.

Revert the changes from commit 2cd3bcea, "grep: add
--warnings={always,never,auto}.", and then do the following:

Reluctant ack. :)

Paolo



reply via email to

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