<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/usr.bin/grep, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>grep/tests: Fix up the zgrep executable path in a newly added test</title>
<updated>2026-01-12T15:34:43+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2026-01-12T13:56:56+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=045112f148fa092c92ec53204708f638b226ff8f'/>
<id>045112f148fa092c92ec53204708f638b226ff8f</id>
<content type='text'>
Fixes:	da5d94d29a5e ("Remove obsolete BUGS section from zgrep(1) man page, add test")
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes:	da5d94d29a5e ("Remove obsolete BUGS section from zgrep(1) man page, add test")
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove obsolete BUGS section from zgrep(1) man page, add test</title>
<updated>2026-01-11T17:53:55+00:00</updated>
<author>
<name>Craig Leres</name>
<email>leres@FreeBSD.org</email>
</author>
<published>2026-01-10T00:34:39+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=da5d94d29a5ec29817476c39ae2b2ad1666c3f06'/>
<id>da5d94d29a5ec29817476c39ae2b2ad1666c3f06</id>
<content type='text'>
I forgot to check/update the man page with D54217. While here add
a test for multiple -e flags.

Reviewed by:	markj
Approved by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54632
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I forgot to check/update the man page with D54217. While here add
a test for multiple -e flags.

Reviewed by:	markj
Approved by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54632
</pre>
</div>
</content>
</entry>
<entry>
<title>grep: add testcase to test color when matches is greater than MAX_MATCHES</title>
<updated>2026-01-09T23:22:48+00:00</updated>
<author>
<name>Viacheslav Chimishuk</name>
<email>vchimishuk@yandex.ru</email>
</author>
<published>2024-10-06T22:18:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=0a5535d1c5209e73c6b2f3fd6118f9ffcb7e296e'/>
<id>0a5535d1c5209e73c6b2f3fd6118f9ffcb7e296e</id>
<content type='text'>
Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/1442
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/1442
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix zgrep(1) wrapper regression, add test</title>
<updated>2025-12-14T21:15:36+00:00</updated>
<author>
<name>Craig Leres</name>
<email>leres@FreeBSD.org</email>
</author>
<published>2025-12-13T23:43:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=80726c2257e9d6d79341aac65ba22987f53619bc'/>
<id>80726c2257e9d6d79341aac65ba22987f53619bc</id>
<content type='text'>
@bdrewery reported D48873 broke "bzgrep -q '1 2' /var/log/messages.0.bz2"
The mistake was in using $* instead of "$@" (I suspect $* is never right).

Reported by:	bdrewery
Reviewed by:	markj
Approved by:	markj
Fixes:		1070477cc8b7 ("Fix remaining zgrep(1) wrapper script regressions")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54217
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
@bdrewery reported D48873 broke "bzgrep -q '1 2' /var/log/messages.0.bz2"
The mistake was in using $* instead of "$@" (I suspect $* is never right).

Reported by:	bdrewery
Reviewed by:	markj
Approved by:	markj
Fixes:		1070477cc8b7 ("Fix remaining zgrep(1) wrapper script regressions")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54217
</pre>
</div>
</content>
</entry>
<entry>
<title>grep: toss in some explicit fflush()</title>
<updated>2025-08-08T05:05:10+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-08-08T04:52:53+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7a7f74dbcc4f41d98218471297eaa629e34326e2'/>
<id>7a7f74dbcc4f41d98218471297eaa629e34326e2</id>
<content type='text'>
grep|tee of the src/ tree for infrequently-occurring strings is fairly
annoying; drop some tactical flushes at line-match boundaries to reduce
the long stalls.  In the case of `grep -o`, we'll flush after multiple
lines if there are multiple matches within a single line of text, while
for non`-o` we'll flush generally after every line.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
grep|tee of the src/ tree for infrequently-occurring strings is fairly
annoying; drop some tactical flushes at line-match boundaries to reduce
the long stalls.  In the case of `grep -o`, we'll flush after multiple
lines if there are multiple matches within a single line of text, while
for non`-o` we'll flush generally after every line.
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace last few remaining MAN[1-8] with MAN</title>
<updated>2025-07-26T10:00:02+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2025-07-26T10:00:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=23401aeb15cec75fc215550b032aa898d2e62455'/>
<id>23401aeb15cec75fc215550b032aa898d2e62455</id>
<content type='text'>
Reviewed by:	ivy
Differential Revision:	https://reviews.freebsd.org/D51530
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reviewed by:	ivy
Differential Revision:	https://reviews.freebsd.org/D51530
</pre>
</div>
</content>
</entry>
<entry>
<title>grep: avoid duplicated lines when we're coloring output</title>
<updated>2025-03-20T04:34:13+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2025-03-20T04:34:13+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=4c9ffb13dd74159bd3ed7e1c4c706dbd15a70df2'/>
<id>4c9ffb13dd74159bd3ed7e1c4c706dbd15a70df2</id>
<content type='text'>
For the default uncolored output, we'll just output a line once and then
move on.  For colored output, we'll output multiple matches per
line with context from the line interspersed and may end up writing out
some match context multiple times as we don't persist which part of the
lines have already been printed.

Fix it by tracking the length of line printed thus far in printline()
and retaining it across successive calls to printline() in the same
line.  printline() should indicate whether it terminated the line or not
to avoid tracking the logic for that in multiple places: -o lines are
always terminated, so it's generally only some --color contexts where we
wouldn't have terminated.

Add a test to make sure that we're only printing one line going forward.

Reported and tested by:	Jamie Landeg-Jones &lt;jamie catflap org&gt;
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D49324
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For the default uncolored output, we'll just output a line once and then
move on.  For colored output, we'll output multiple matches per
line with context from the line interspersed and may end up writing out
some match context multiple times as we don't persist which part of the
lines have already been printed.

Fix it by tracking the length of line printed thus far in printline()
and retaining it across successive calls to printline() in the same
line.  printline() should indicate whether it terminated the line or not
to avoid tracking the logic for that in multiple places: -o lines are
always terminated, so it's generally only some --color contexts where we
wouldn't have terminated.

Add a test to make sure that we're only printing one line going forward.

Reported and tested by:	Jamie Landeg-Jones &lt;jamie catflap org&gt;
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D49324
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix remaining zgrep(1) wrapper script regressions</title>
<updated>2025-02-09T18:45:03+00:00</updated>
<author>
<name>Craig Leres</name>
<email>leres@FreeBSD.org</email>
</author>
<published>2025-02-08T21:19:54+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1070477cc8b7a88b1fd2b1ba810a1fff761799a1'/>
<id>1070477cc8b7a88b1fd2b1ba810a1fff761799a1</id>
<content type='text'>
Summary:
Fix short flags without whitespace, e.g:

    zgrep -wefoo test

Fix multiple -e flags:

    zgrep -e foo -e xxx test

Previously only the last pattern would be used.

Clean up possible leading blank in ${grep_args}.

Update comment: 2.51 -&gt; 2.6.0

Add a test case for the last known zgrep wrapper issue: recursion
(-r) not implemented.

Reviewers: markj, kevans, ngie, bapt

Reviewed By: markj

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D48873
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
Fix short flags without whitespace, e.g:

    zgrep -wefoo test

Fix multiple -e flags:

    zgrep -e foo -e xxx test

Previously only the last pattern would be used.

Clean up possible leading blank in ${grep_args}.

Update comment: 2.51 -&gt; 2.6.0

Add a test case for the last known zgrep wrapper issue: recursion
(-r) not implemented.

Reviewers: markj, kevans, ngie, bapt

Reviewed By: markj

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D48873
</pre>
</div>
</content>
</entry>
<entry>
<title>grep: Default to -p instead of -S.</title>
<updated>2024-09-04T19:53:22+00:00</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2024-09-04T19:53:22+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fc12c191c087b63e1204fee210ba76082ea40b96'/>
<id>fc12c191c087b63e1204fee210ba76082ea40b96</id>
<content type='text'>
This matches the documented behavior in the manpage as well as the
default behavior on macOS.

PR:		280676
Reported by:	Radosław Piliszek &lt;radoslaw.piliszek@gmail.com&gt;
Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D46256
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This matches the documented behavior in the manpage as well as the
default behavior on macOS.

PR:		280676
Reported by:	Radosław Piliszek &lt;radoslaw.piliszek@gmail.com&gt;
Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D46256
</pre>
</div>
</content>
</entry>
<entry>
<title>grep: Fix various bugs in recursive tree handling</title>
<updated>2024-09-04T19:53:17+00:00</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2024-09-04T19:53:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=77eb877714d69ee0279d70eb3331920fba90db95'/>
<id>77eb877714d69ee0279d70eb3331920fba90db95</id>
<content type='text'>
The -OpS options were effectively ignored due to a collection of
bugs in the use of fts(3):

- fts_open(3) requires one of FTS_PHYSICAL or FTS_LOGICAL to be
  specified, but in the -O case, only FTS_COMFOLLOW was given.  Fix
  this to use FTS_COMFOLLOW | FTS_PHYSICAL.

- The switch on the entry type returned by fts_read() did not check
  for symbolic links, so symbolic links fell into the default case and
  were always passed to procfile() even when -p was given.  Fix this
  by adding cases in the switch statement to explicitly ignore FTS_SL.

- FTS_NOSTAT was passed to fts_open(), so fts_open() couldn't detect
  symbolic links when FTS_PHYSICAL was passed, instead both regular
  files and symbolic links were returned as FTS_NSOK entries.  Fix
  by only using FTS_NOSTAT with FTS_LOGICAL.

While here, fix a few other nits:

- Treat FTS_NS as an error like FTS_DNR and FTS_ERR.

- Just ignore FTS_DP.  The logic to skip descending into skipped
  directories is only relevant when a directory is first visited, not
  after the directory has been visited.

- Use warnc instead of warnx + strerror.

PR:		280676
Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D46255
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The -OpS options were effectively ignored due to a collection of
bugs in the use of fts(3):

- fts_open(3) requires one of FTS_PHYSICAL or FTS_LOGICAL to be
  specified, but in the -O case, only FTS_COMFOLLOW was given.  Fix
  this to use FTS_COMFOLLOW | FTS_PHYSICAL.

- The switch on the entry type returned by fts_read() did not check
  for symbolic links, so symbolic links fell into the default case and
  were always passed to procfile() even when -p was given.  Fix this
  by adding cases in the switch statement to explicitly ignore FTS_SL.

- FTS_NOSTAT was passed to fts_open(), so fts_open() couldn't detect
  symbolic links when FTS_PHYSICAL was passed, instead both regular
  files and symbolic links were returned as FTS_NSOK entries.  Fix
  by only using FTS_NOSTAT with FTS_LOGICAL.

While here, fix a few other nits:

- Treat FTS_NS as an error like FTS_DNR and FTS_ERR.

- Just ignore FTS_DP.  The logic to skip descending into skipped
  directories is only relevant when a directory is first visited, not
  after the directory has been visited.

- Use warnc instead of warnx + strerror.

PR:		280676
Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D46255
</pre>
</div>
</content>
</entry>
</feed>
