|Summary:||Improper behaviour of GNU grep(1)|
|Product:||Base System||Reporter:||Artem Perekresny <kondybas>|
|Component:||gnu||Assignee:||freebsd-bugs mailing list <bugs>|
|Severity:||Affects Only Me||CC:||ache, emaste, kevans|
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 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 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 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 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. =)