Bug 156704 - Improper behaviour of GNU grep(1)
Summary: Improper behaviour of GNU grep(1)
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: gnu (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-28 20:30 UTC by Artem Perekresny
Modified: 2018-05-20 23:50 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Artem Perekresny 2011-04-28 20:30:10 UTC
grep (GNU grep) 2.5.1-FreeBSD fails on "-o" option 

When pattern is alternatives joined with "|" option "-o" produce every possible matches ignoring "^", "\<", "\b" etc.

How-To-Repeat: # cat file.txt
ABCD
# egrep -o "^A" file.txt
A
# egrep -o "^B" file.txt
# egrep -o "^A|^B|^C|^D" file.txt
A
B
C
D
# cat file2.txt
DCBA
# egrep -o "^A|^B|^C|^D" file2.txt
D
C
B
A
#
Comment 1 Alexander Best freebsd_committer 2011-04-29 10:33:34 UTC
just tried this with BSD grep and there the issue is not reproducable.

i'm quite sure this has already been fixed in gnu grep, however one needs to
check, whether this was done before or after the switch to gplv3.

cheers.
alex

-- 
a13x
Comment 2 Kyle Evans freebsd_committer 2017-04-20 17:23:56 UTC
This is also an issue with GNU grep alone, and not libgnuregex. This one safely goes away when BSD grep is installed as /usr/bin/grep.
Comment 3 Andrey A. Chernov freebsd_committer 2017-04-20 18:56:10 UTC
(In reply to Kyle Evans from comment #2)
I also suggest to install GNU grep from our ports instead of using obsoleted (due to its licensing) GNU grep we have, there are a lot of bugs fixed (I don't check this particular bug).
Comment 4 Kyle Evans freebsd_committer 2017-04-20 19:04:27 UTC
(In reply to Andrey A. Chernov from comment #3)

I can confirm that this bug has been addressed in newer versions of GNU grep. =)
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:50:15 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"