Skip to content

grep: keep invalid UTF-8 text under -I - #49

Merged
lhecker merged 1 commit into
uutils:mainfrom
wondr-wclabs:codex/without-match-invalid-utf8
Jun 5, 2026
Merged

lhecker merged 1 commit into
uutils:mainfrom
wondr-wclabs:codex/without-match-invalid-utf8

Conversation

@wondr-wclabs

Copy link
Copy Markdown
Contributor

Closes #9.

--binary-files=without-match should suppress files once they are actually classified as binary. In this implementation NUL detection already happens before matching and still takes that path. The issue was the later invalid-UTF-8 check on matching lines: under -I, a matching high byte such as \x9d was enough to mark the session binary and return no match.

This keeps the change narrow by skipping only that invalid-UTF-8 binary classification when binary_mode is WithoutMatch. Default binary mode still reports a matching invalid-UTF-8 line as binary, and --binary-files=text remains unchanged. NUL bytes still make -I suppress output and exit with no match.

The regression coverage extends the existing binary_files_without_match_skips test with both -I and --binary-files=without-match invalid-UTF-8 cases, while retaining the NUL skip cases.

@codspeed

codspeed Bot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing wondr-wclabs:codex/without-match-invalid-utf8 (1d0d316) with main (f4798cb)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@lhecker lhecker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lhecker
lhecker merged commit 7c79cb4 into uutils:main Jun 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

handles --binary-files=without-match on invalid-UTF-8 lines differently from GNU (treats a matching line as binary and suppresses it)

2 participants