Bug 242308 - grep -b, --byte-offset returns 0
Summary: grep -b, --byte-offset returns 0
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-30 00:07 UTC by Marvin Jones
Modified: 2019-12-02 18:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marvin Jones 2019-11-30 00:07:37 UTC
(My brand new login - first time reporting a bug - apologies if...)

grep'ping for a byte offset always returns 0 for the result.
Searching "FreeBSD Bugzilla – Bug List" shows no other reports.

Ubuntu 16.04:

jonesy@nix5:~$ a='now is the time for all good men to come to the aid of the party'
jonesy@nix5:~$ echo $a | grep -b -o  good
24:good


FreeBSD 12.1 

[jonz~]a='now is the time for all good men to come to the aid of the party'
[jonz~]echo $a | grep -b -o  good
0:good
Comment 1 Masachika ISHIZUKA 2019-11-30 00:39:29 UTC
(In reply to Marvin Jones from comment #0)

/usr/bin/grep in 13-current has the same bug.
gnugrep in ports/textproc works fine.
Comment 2 Ed Maste freebsd_committer 2019-12-02 18:11:22 UTC
Thank you for the report.

I build WITH_BSD_GREP and it doesn't have this problem:

% grep --version
grep (BSD grep) 2.6.0-FreeBSD
% a='now is the time for all good men to come to the aid of the party'
% echo $a | grep -b -o good
24:good

The most likely fix for this in FreeBSD is to wrap up the rest of the work to make BSD_GREP the default.