public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* bug with grep 3.0.2 in cygwin 3.0.7
       [not found] <1910922536.1217465852.1566975322390.JavaMail.root@zimbra76-e14.priv.proxad.net>
@ 2019-08-28  8:32 ` akiki
  2019-08-28 12:51   ` Eliot Moss
                     ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: akiki @ 2019-08-28  8:32 UTC (permalink / raw)
  To: cygwin

Hi, 
I encounter some problem with grep option -E on cygwin 3.0.7 


echo "a^b" | grep "a^b" #answer a^b ie it's OK 
but 
echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO 


I have to backslash ^ to be OK like : grep -E 'a\^b' 


Is-it a bug ? 
I don't know if all versions of cygwin and grep are concerned. 


My cygcheck is OK with: 

Windows 10 Professional Ver 10.0 Build 18362 


Running under WOW64 on AMD64 
... 

3218k 2019/04/30 C:\ws\njcyg\bin\cygwin1.dll 
Cygwin DLL version info: 
DLL version: 3.0.7 
DLL epoch: 19 
DLL old termios: 5 
DLL malloc env: 28 
Cygwin conv: 181 
API major: 0 
API minor: 338 
Shared data: 5 
DLL identifier: cygwin1 
Mount registry: 3 
Cygwin registry name: Cygwin 
Installations name: Installations 
Cygdrive default prefix: 
Build date: 
Shared id: cygwin1S5 
... 
grep 3.0-2 OK 


=============== 


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-28  8:32 ` bug with grep 3.0.2 in cygwin 3.0.7 akiki
@ 2019-08-28 12:51   ` Eliot Moss
  2019-08-28 13:33   ` Eric Blake
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Eliot Moss @ 2019-08-28 12:51 UTC (permalink / raw)
  To: cygwin

On 8/28/2019 3:16 AM, akiki@free.fr wrote:
> Hi,
> I encounter some problem with grep option -E on cygwin 3.0.7
> 
> 
> echo "a^b" | grep "a^b" #answer a^b ie it's OK
> but
> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
> 
> 
> I have to backslash ^ to be OK like : grep -E 'a\^b'
> 
> 
> Is-it a bug ?
> I don't know if all versions of cygwin and grep are concerned.

 From my reading of the man page, it's either a program bug or a
documentation bug.  It could well be the latter since -E extended
regular expressions require a number of other metacharacters to
be backslash quoted.  However, the documentation does not mention
the ^ metacharacter.

Regards - EM

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-28  8:32 ` bug with grep 3.0.2 in cygwin 3.0.7 akiki
  2019-08-28 12:51   ` Eliot Moss
@ 2019-08-28 13:33   ` Eric Blake
  2019-08-29 19:20   ` Andrey Repin
  2019-09-23 14:42   ` Chris Wagner
  3 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2019-08-28 13:33 UTC (permalink / raw)
  To: cygwin, akiki


[-- Attachment #1.1: Type: text/plain, Size: 2111 bytes --]

On 8/28/19 2:16 AM, akiki@free.fr wrote:
> Hi, 
> I encounter some problem with grep option -E on cygwin 3.0.7 
> 
> 
> echo "a^b" | grep "a^b" #answer a^b ie it's OK 

POSIX says:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

"A BRE special character has special properties in certain contexts.
Outside those contexts, or when preceded by a <backslash>, such a
character is a BRE that matches the special character itself."
...
"A <circumflex> ( '^' ) shall be an anchor when used as the first
character of an entire BRE. The implementation may treat the
<circumflex> as an anchor when used as the first character of a
subexpression."

Since ^ is only special as the first character or in a [], and you have
used it for neither, this is a well-specified literal match.

> but 
> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO 

"An ERE special character has special properties in certain contexts.
Outside those contexts, or when preceded by a <backslash>, such a
character shall be an ERE that matches the special character itself."

"A <circumflex> ( '^' ) outside a bracket expression shall anchor the
expression or subexpression it begins to the beginning of a string; such
an expression or subexpression can match only a sequence starting at the
first character of a string. For example, the EREs "^ab" and "(^ab)"
match "ab" in the string "abcdef", but fail to match in the string
"cdefab", and the ERE "a^b" is valid, but can never match because the
'a' prevents the expression "^b" from matching starting at the first
character."

So in ERE, ^ is an anchor anywhere, while in BRE, ^ is an anchor only as
the first byte.  The difference you are observing matches POSIX.

> 
> 
> I have to backslash ^ to be OK like : grep -E 'a\^b' 

Correct.

> 
> 
> Is-it a bug ? 

No. (In fact, if you test on Linux, you'll see the same behavior, which
shows it is not specific to Cygwin).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-28  8:32 ` bug with grep 3.0.2 in cygwin 3.0.7 akiki
  2019-08-28 12:51   ` Eliot Moss
  2019-08-28 13:33   ` Eric Blake
@ 2019-08-29 19:20   ` Andrey Repin
  2019-08-30  6:12     ` Eliot Moss
  2019-09-23 14:42   ` Chris Wagner
  3 siblings, 1 reply; 11+ messages in thread
From: Andrey Repin @ 2019-08-29 19:20 UTC (permalink / raw)
  To: akiki, cygwin

Greetings, akiki@free.fr!

> Hi, 
> I encounter some problem with grep option -E on cygwin 3.0.7 


> echo "a^b" | grep "a^b" #answer a^b ie it's OK 
> but 
> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO 

That's an expected result of an impossible constraint.

> I have to backslash ^ to be OK like : grep -E 'a\^b' 

Yes.

> Is-it a bug ?

No.

> I don't know if all versions of cygwin and grep are concerned. 

RTFM, this is regexp basics.


-- 
With best regards,
Andrey Repin
Thursday, August 29, 2019 22:07:04

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-29 19:20   ` Andrey Repin
@ 2019-08-30  6:12     ` Eliot Moss
  2019-08-30  7:48       ` Brian Inglis
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Eliot Moss @ 2019-08-30  6:12 UTC (permalink / raw)
  To: cygwin

On 8/29/2019 3:08 PM, Andrey Repin wrote:
> Greetings, akiki@free.fr!
> 
>> Hi,
>> I encounter some problem with grep option -E on cygwin 3.0.7
> 
> 
>> echo "a^b" | grep "a^b" #answer a^b ie it's OK
>> but
>> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
> 
> That's an expected result of an impossible constraint.
> 
>> I have to backslash ^ to be OK like : grep -E 'a\^b'
> 
> Yes.
> 
>> Is-it a bug ?
> 
> No.
> 
>> I don't know if all versions of cygwin and grep are concerned.
> 
> RTFM, this is regexp basics.

There was a really great answer to this earlier.  I tried an
answer, but was wrong.  One has to read the "fine print" really
carefully.  At first I thought it was a bug, at least in the
documentation, but the meaning of a^b, when ^ is the metacharacter,
is kind of subtle (IMO at least).  It's easy to miss that
subtlety and think that if ^ is not at the beginning of an
expression it will be treated as an ordinary character ...

But my main point is that RTM would be enough; RTFM seemed
to me perhaps a little more rude than necessary.

Regards - EM

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-30  6:12     ` Eliot Moss
@ 2019-08-30  7:48       ` Brian Inglis
  2019-08-30 15:34         ` Eliot Moss
  2019-08-30  7:50       ` Duncan Roe
  2019-08-30  7:55       ` Andrey Repin
  2 siblings, 1 reply; 11+ messages in thread
From: Brian Inglis @ 2019-08-30  7:48 UTC (permalink / raw)
  To: cygwin

On 2019-08-29 19:42, Eliot Moss wrote:
> On 8/29/2019 3:08 PM, Andrey Repin wrote:
>>> I encounter some problem with grep option -E on cygwin 3.0.7
>>> echo "a^b" | grep "a^b" #answer a^b ie it's OK
>>> but
>>> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
>> That's an expected result of an impossible constraint.
>>> I have to backslash ^ to be OK like : grep -E 'a\^b'
>> Yes.
>>> Is-it a bug ?
>> No.
>>> I don't know if all versions of cygwin and grep are concerned.
>> RTFM, this is regexp basics.
> There was a really great answer to this earlier.  I tried an
> answer, but was wrong.  One has to read the "fine print" really
> carefully.  At first I thought it was a bug, at least in the
> documentation, but the meaning of a^b, when ^ is the metacharacter,
> is kind of subtle (IMO at least).  It's easy to miss that
> subtlety and think that if ^ is not at the beginning of an
> expression it will be treated as an ordinary character ...
> But my main point is that RTM would be enough; RTFM seemed
> to me perhaps a little more rude than necessary.

https://cygwin.com/acronyms/#RTFM exists and has been amusing rather than rude
in our industry for decades, especially in non-native English locales e.g. here
in this list: "Read The Fine Manual"; but RTM for software products is usually
"Release To Manufacturing", from the days when media was produced!

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-30  6:12     ` Eliot Moss
  2019-08-30  7:48       ` Brian Inglis
@ 2019-08-30  7:50       ` Duncan Roe
  2019-08-30 13:04         ` Jose Isaias Cabrera
  2019-08-30  7:55       ` Andrey Repin
  2 siblings, 1 reply; 11+ messages in thread
From: Duncan Roe @ 2019-08-30  7:50 UTC (permalink / raw)
  To: cygwin

On Thu, Aug 29, 2019 at 09:42:46PM -0400, Eliot Moss wrote:
> On 8/29/2019 3:08 PM, Andrey Repin wrote:
> > Greetings, akiki@free.fr!
> >
> > > Hi,
> > > I encounter some problem with grep option -E on cygwin 3.0.7
> >
> >
> > > echo "a^b" | grep "a^b" #answer a^b ie it's OK
> > > but
> > > echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
> >
> > That's an expected result of an impossible constraint.
> >
> > > I have to backslash ^ to be OK like : grep -E 'a\^b'
> >
> > Yes.
> >
> > > Is-it a bug ?
> >
> > No.
> >
> > > I don't know if all versions of cygwin and grep are concerned.
> >
> > RTFM, this is regexp basics.
>
> There was a really great answer to this earlier.  I tried an
> answer, but was wrong.  One has to read the "fine print" really
> carefully.  At first I thought it was a bug, at least in the
> documentation, but the meaning of a^b, when ^ is the metacharacter,
> is kind of subtle (IMO at least).  It's easy to miss that
> subtlety and think that if ^ is not at the beginning of an
> expression it will be treated as an ordinary character ...
>
> But my main point is that RTM would be enough; RTFM seemed
> to me perhaps a little more rude than necessary.
>
> Regards - EM
>
I don't see anything to object to in "Read The Fine Manual" ;)

Cheers ... Duncan.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-30  6:12     ` Eliot Moss
  2019-08-30  7:48       ` Brian Inglis
  2019-08-30  7:50       ` Duncan Roe
@ 2019-08-30  7:55       ` Andrey Repin
  2 siblings, 0 replies; 11+ messages in thread
From: Andrey Repin @ 2019-08-30  7:55 UTC (permalink / raw)
  To: Eliot Moss, cygwin

Greetings, Eliot Moss!

>>> I encounter some problem with grep option -E on cygwin 3.0.7
>> 
>> 
>>> echo "a^b" | grep "a^b" #answer a^b ie it's OK
>>> but
>>> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
>> 
>> That's an expected result of an impossible constraint.
>> 
>>> I have to backslash ^ to be OK like : grep -E 'a\^b'
>> 
>> Yes.
>> 
>>> Is-it a bug ?
>> 
>> No.
>> 
>>> I don't know if all versions of cygwin and grep are concerned.
>> 
>> RTFM, this is regexp basics.

> There was a really great answer to this earlier.  I tried an
> answer, but was wrong.  One has to read the "fine print" really
> carefully.  At first I thought it was a bug, at least in the
> documentation, but the meaning of a^b, when ^ is the metacharacter,
> is kind of subtle (IMO at least).  It's easy to miss that
> subtlety and think that if ^ is not at the beginning of an
> expression it will be treated as an ordinary character ...

> But my main point is that RTM would be enough; RTFM seemed
> to me perhaps a little more rude than necessary.

Adding to the earlier answers (sorry, replying on the road is not efficient),
there's a https://www.regular-expressions.info/
Which contains a great deal of information about RE, their kinds, caveats and
implementations in various languages.


-- 
With best regards,
Andrey Repin
Friday, August 30, 2019 10:42:35

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-30  7:50       ` Duncan Roe
@ 2019-08-30 13:04         ` Jose Isaias Cabrera
  0 siblings, 0 replies; 11+ messages in thread
From: Jose Isaias Cabrera @ 2019-08-30 13:04 UTC (permalink / raw)
  To: Duncan Roe, cygwin


Duncan Roe, on Friday, August 30, 2019 03:47 AM, wrote...
>
> On Thu, Aug 29, 2019 at 09:42:46PM -0400, Eliot Moss wrote:
> > On 8/29/2019 3:08 PM, Andrey Repin wrote:

> > But my main point is that RTM would be enough; RTFM seemed
> > to me perhaps a little more rude than necessary.
> >
> > Regards - EM
> >
> I don't see anything to object to in "Read The Fine Manual" ;)

You know real well what the F in RTFM stands for: Functioning.  And that, my friend, is a little too much nowadays for them sensitivity unchallenged folks.  Just my 102 Dominican cents. :-)

josé

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-30  7:48       ` Brian Inglis
@ 2019-08-30 15:34         ` Eliot Moss
  0 siblings, 0 replies; 11+ messages in thread
From: Eliot Moss @ 2019-08-30 15:34 UTC (permalink / raw)
  To: cygwin

On 8/30/2019 2:12 AM, Brian Inglis wrote:
> On 2019-08-29 19:42, Eliot Moss wrote:
>> On 8/29/2019 3:08 PM, Andrey Repin wrote:
>>>> I encounter some problem with grep option -E on cygwin 3.0.7
>>>> echo "a^b" | grep "a^b" #answer a^b ie it's OK
>>>> but
>>>> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
>>> That's an expected result of an impossible constraint.
>>>> I have to backslash ^ to be OK like : grep -E 'a\^b'
>>> Yes.
>>>> Is-it a bug ?
>>> No.
>>>> I don't know if all versions of cygwin and grep are concerned.
>>> RTFM, this is regexp basics.
>> There was a really great answer to this earlier.  I tried an
>> answer, but was wrong.  One has to read the "fine print" really
>> carefully.  At first I thought it was a bug, at least in the
>> documentation, but the meaning of a^b, when ^ is the metacharacter,
>> is kind of subtle (IMO at least).  It's easy to miss that
>> subtlety and think that if ^ is not at the beginning of an
>> expression it will be treated as an ordinary character ...
>> But my main point is that RTM would be enough; RTFM seemed
>> to me perhaps a little more rude than necessary.
> 
> https://cygwin.com/acronyms/#RTFM exists and has been amusing rather than rude
> in our industry for decades, especially in non-native English locales e.g. here
> in this list: "Read The Fine Manual"; but RTM for software products is usually
> "Release To Manufacturing", from the days when media was produced!

Ok, I relent!  E

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: bug with grep 3.0.2 in cygwin 3.0.7
  2019-08-28  8:32 ` bug with grep 3.0.2 in cygwin 3.0.7 akiki
                     ` (2 preceding siblings ...)
  2019-08-29 19:20   ` Andrey Repin
@ 2019-09-23 14:42   ` Chris Wagner
  3 siblings, 0 replies; 11+ messages in thread
From: Chris Wagner @ 2019-09-23 14:42 UTC (permalink / raw)
  To: cygwin, akiki

On 2019-08-28 3:16 am, akiki@free.fr wrote:
> Hi,
> I encounter some problem with grep option -E on cygwin 3.0.7
> 
> 
> echo "a^b" | grep "a^b" #answer a^b ie it's OK
> but
> echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO
> 
> 
> I have to backslash ^ to be OK like : grep -E 'a\^b'
> 
> 
> Is-it a bug ?
> I don't know if all versions of cygwin and grep are concerned.

Hi Akiki.  As others mentioned, it has to do with how regular 
expressions operate.  However the best solution for you in this 
situation is to not use regular expressions.  To search for fixed 
strings, use fgrep or grep -F.  That avoids all issues with meta 
characters and covers the vast majority of cases when we use grep 
anyway.

To use full power regular expressions read perlre and use grep -P.


Thanks.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-09-22 18:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1910922536.1217465852.1566975322390.JavaMail.root@zimbra76-e14.priv.proxad.net>
2019-08-28  8:32 ` bug with grep 3.0.2 in cygwin 3.0.7 akiki
2019-08-28 12:51   ` Eliot Moss
2019-08-28 13:33   ` Eric Blake
2019-08-29 19:20   ` Andrey Repin
2019-08-30  6:12     ` Eliot Moss
2019-08-30  7:48       ` Brian Inglis
2019-08-30 15:34         ` Eliot Moss
2019-08-30  7:50       ` Duncan Roe
2019-08-30 13:04         ` Jose Isaias Cabrera
2019-08-30  7:55       ` Andrey Repin
2019-09-23 14:42   ` Chris Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).