Summary: | grep(1) and bsdgrep(1) do not recognize [[:<:]] and [[:>:]] | ||
---|---|---|---|
Product: | Base System | Reporter: | Nathan Weeks <nathan.weeks> |
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed FIXED | ||
Severity: | Affects Many People | CC: | emaste, kevans, ngie, wosch |
Priority: | --- | ||
Version: | 9.2-RELEASE | ||
Hardware: | Any | ||
OS: | Any | ||
URL: | https://reviews.freebsd.org/D10114 |
Description
Nathan Weeks
2014-06-16 13:33:20 UTC
(In reply to weeks from comment #0) Hi, This is another issue that comes with GNU_GREP_COMPAT. I don't suspect there's much hope that this will change, though -- tested on a relatively new Debian system, GNU grep and sed *both* fail recognize these as character classes. This is otherwise resolved by compiling bsdgrep with WITHOUT_GNU_GREP_COMPAT="YES" set in /etc/src.conf. OK. It's interesting to note that OS X 10.11.6, which also uses bsdgrep, does support the '[[:<:]]' and '[[:>:]]' bracket expressions: $ uname -srv Darwin 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 $ type grep grep is a tracked alias for /usr/bin/grep $ grep --version grep (BSD grep) 2.5.1-FreeBSD $ printf 'foobar\nfoo bar\nbaz' | grep 'foo[[:>:]]' foo bar $ printf 'foobar\nfoo bar\nbaz' | grep '[[:<:]]bar' foo bar > OK. It's interesting to note that OS X 10.11.6, which also uses bsdgrep, does
> support the '[[:<:]]' and '[[:>:]]' bracket expressions:
Apple's bsdgrep has a few bug fixes. Unfortunately I've not yet been able to find the source for these changes.
(In reply to weeks from comment #2) Yeah, the odds are quite good that they don't have an option that uses GNU regex stuff instead of their own, which is the problem that we have. Our regex stuff supports it, but GNU's does not and linking against GNU is the default here. I've pondered elsewhere if it would be a good idea to make this not the default on a BSD system, and again it would seem to be a good idea. (In reply to Ed Maste from comment #3) It's buried somewhere in here: https://opensource.apple.com/release/macos-10122.html . (In reply to Ngie Cooper from comment #5) Here it is: https://opensource.apple.com/source/text_cmds/text_cmds-97/grep/ . (In reply to Ngie Cooper from comment #6) > https://opensource.apple.com/source/text_cmds/text_cmds-97/grep/ . Great, thanks! It's not in the text_cmds source package prior to 10.12 and wasn't available last time I looked. I'm glad this has been addressed. A lot of the problems are fixed by the two or three patches I've recently submitted, a couple others (like this one) would go away fairly easily if we could not do this (block) by default: https://svnweb.freebsd.org/base/head/usr.bin/grep/Makefile?view=markup#l78 These things combined would leave us with ~4 remaining bsdgrep issues to work with, and I'm not immediately certain if those ones are really unrelated. See review D10114 - we will switch GNU_GREP_COMPAT off by default, which will address this issue. For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open" A commit references this bug: Author: kevans Date: Tue Dec 8 14:05:27 UTC 2020 New revision: 368439 URL: https://svnweb.freebsd.org/changeset/base/368439 Log: src.opts.mk: switch to bsdgrep as /usr/bin/grep This has been years in the making, and we all knew it was bound to happen some day. Switch to the BSDL grep implementation now that it's been a little more thoroughly tested and theoretically supports all of the extensions that gnugrep in base had with our libregex(3). Folks shouldn't really notice much from this update; bsdgrep is slower than gnugrep, but this is currently the price to pay for fewer bugs. Those dissatisfied with the speed of grep and in need of a faster implementation should check out what textproc/ripgrep and textproc/the_silver_searcher can do for them. I have some WIP to make bsdgrep faster, but do not consider it a blocker when compared to the pros of switching now (aforementioned bugs, licensing). PR: 228798 (exp-run) PR: 128645, 156704, 166842, 166862, 180937, 193835, 201650 PR: 232565, 242308, 246000, 251081, 191086, 194397 Relnotes: yes, please Changes: head/share/mk/src.opts.mk I cannot reproduce the issue with bsdgrep anymore, only for gnugrep. Closing. |