[Bug 105221] grep(1): `grep -w -F ""` issue

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Apr 19 23:19:06 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=105221

Kyle Evans <bsdports at kyle-evans.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bsdports at kyle-evans.net,
                   |                            |emaste at freebsd.org

--- Comment #3 from Kyle Evans <bsdports at kyle-evans.net> ---
Some notes:

bsdgrep(1) is also affected in a different way by this old, old bug, so some
notes:

gnugrep currently in base still exhibits the original behavior
bsdgrep will match the string
textproc/gnugrep will fail to match, presumably because it matches the 0-length
BOL at the beginning of the string and the character immediately following it
("q") is a word character

Here's some other interesting behavior from textproc/gnugrep:

$ echo "" | fgrep -w ""

# Empty string, exit = 0, OK, that's..interesting
$ echo "qaz" | fgrep -w ""
# exit = 1, expected
$ echo " qaz" | fgrep -w ""
 qaz
$ printf "" | fgrep -w ""
# exit = 1, expected

On one hand, I don't agree with the idea that a 0-length match can *ever*
produce a whole-word match- this seems misleading and probably not a practical
use case.

On the other hand, this is technically correct behavior because the 0-length
match is at the beginning of the string with a non-word-character on its other
side.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list