bug-grep
[Top][All Lists]
Advanced

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

Re: have you ever mistyped [[:lower:]] as [:lower:] ?


From: Jim Meyering
Subject: Re: have you ever mistyped [[:lower:]] as [:lower:] ?
Date: Wed, 01 Sep 2010 15:45:03 +0200

Paolo Bonzini wrote:

> On 09/01/2010 02:51 PM, Jim Meyering wrote:
>> Who knows... POSIX may allow this new behavior, someday.
>> Wouldn't you adjust sed if POSIX were to permit special
>> handling of obviously-erroneous regular expressions?
>
> Permit, I don't know. Mandate, of course.  In any case, I don't want
> to lead the way.

Perhaps you'll reconsider when you see all of the invalid character
class syntax in sed regular expressions here (currently there are 286):

http://www.google.com/codesearch?hl=en&lr=&q=\bsed\+[^[|]*\[%3A%28alnum|alpha|cntrl|digit|graph|lower|print|punct|space|upper|xdigit%29%3A\]&sbtn=Search

>>> It's a huge mistake, because making it an error means
>>> changing the regex grammar (and making it unnecessarily complicated
>>> and contrived).
>>
>> It's already done in grep, and wasn't a very big change.
>
> You're conflating the formal grammar and the code that implements
> it. The latter is allowed to include this kind of "hack", the former
> cannot. POSIX

It's done for grep.
I see no need to change any formal grammar.

>> > I still think this is wrong, and doubly wrong because I cannot disable
>> > it on my system without breaking it with POSIXLY_CORRECT.  Please,
>>
>> You want to disable it?
>> I doubt you intend to use grep '[:space:]'...,
>> so I still fail to understand why you would want that.
>
> Just because I value the difference between "syntactic validation"
> (errors) and "semantic validation" (warnings).  Call me a purist. :)
>
>> It sounds like you're upset.
>> Sorry it's come to that, but I feel strongly about this, too.
>
> I'm not upset, but I'm very much worried of making a mistake.  What if
> someone proposes to warn for [A-Z] and [a-z] whenever they're not
> going to do what the user thinks (they're not synonyms of any of
> [[:upper:]], [[:lower:]], [[:alpha:]])?  Are we going to make that an
> error?

"We have nothing to fear but fear itself".
But I doubt you're seriously worried about [A-Z], etc.

If you are, don't worry.  Any maintainer who proposed or accepted such
a thing (as the default) would be quickly pummeled into submission
by sensible readers.  The proposer would not even have to retract his
proposal, since the feedback would have made it so obvious that it's
undesirable.

Besides, the risk of someone proposing some future warning
has no bearing on the current situation.

> Also, I'm trying to mediate though between our positions.  What's
> wrong with the alternative plan I outlined?  Actually I'm more upset
> because you didn't answer that part. :)

I explained in a previous reply why I don't want the new option.
It wouldn't (and shouldn't) be used in scripts, and I want
the default to be "error", even (perhaps "especially") in scripts



reply via email to

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