Add content-search predicates: -content/-icontent (literal) + -rxc/-irxc (regex) - #195
Merged
Conversation
The plain renderer can now C-escape path bytes so a newline or control character in a filename cannot corrupt the line-oriented -print stream: --path-encoding=escape turns `\` and control bytes into `\\`, `\n`, `\t`, `\r`, or `\xNN`; raw (the default) stays verbatim and find-compatible. It applies to the plain format only -- kNul keeps raw bytes (the NUL is the separator) and kJsonl always JSON-escapes. render::Renderer gains a PathEncoding; run.cc ResolvePathEncoding mirrors ResolveFormat (last wins, raw default) and feeds the implicit-print renderer. Self-documented via the globals table + kHelpText (so --help/--man/--markdown list it). render_test covers escape/raw and that it applies only to plain. The other half of #45 (--exact, filesystem-native matching) remains.
…rxc (regex) File-content search (rg/fd parity): the xff counterpart of -name/-regex, but over a file's bytes instead of its path. -content STR / -icontent STR literal substring (i = ASCII case-fold) -rxc RE / -irxc RE RE2 regex, unanchored (PartialMatch) All four are xff extensions (--config=find rejects them) and Cost::kExpensive (they read the file). Binary files are skipped by default via a NUL-byte sniff over the first 8 KiB (grep/ripgrep behaviour). The name -grep was deliberately rejected: grep's BRE/ERE/-P flavor baggage is ambiguous for both a literal and a single-flavor-regex predicate. Mechanism: - regex::Matcher::PartialMatch (RE2::PartialMatch), backing -rxc/-irxc. - vfs::FileSystem::ReadContent (whole-file read) across all implementers: LocalFs uses a POSIX read loop, DryRunFileSystem delegates, the test fakes stub it. - evaluate.cc ContentToSearch (type-gate + read + binary sniff) + EvalContent/EvalRxc. - parser CompileNodeRegex precompiles -rxc/-irxc like -regex/-iregex. Self-documentation in the same change (registry SOT): four Descriptor summaries (flow into --help / --help=NAME / --man / --markdown), the kHelpText expression summary, and a resolved-names note in docs/design.md superseding the -contains/-grep placeholders. Tests: regex PartialMatch; LocalFs::ReadContent; evaluate_test literal / regex / case-fold / binary-skip / non-regular; content_test.sh end-to-end (incl. find-style gating and the --help topic).
helly25
enabled auto-merge (squash)
June 28, 2026 14:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File-content search (ripgrep/fd parity): the xff counterpart of
-name/-regex, but over a file's bytes instead of its path.-content STR-icontent STR-content, ASCII case-folded-rxc REPartialMatch)-irxc RE-rxc, case-insensitiveAll four are xff extensions (
--config=findrejects them) andCost::kExpensive(they read the file). Binary files are skipped by default via a NUL-byte sniff over the first 8 KiB (grep/ripgrep behaviour).Naming
-grepwas deliberately rejected: grep's BRE/ERE/-Pflavor baggage makes it ambiguous for both a literal and a single-flavor-regex predicate.-contentis unambiguous;-rxc(rx=regex,c=content) sidesteps "which grep regex?" entirely.Mechanism
regex::Matcher::PartialMatch(RE2PartialMatch), backing-rxc/-irxc.vfs::FileSystem::ReadContent(whole-file read) across all implementers:LocalFsPOSIX read loop,DryRunFileSystemdelegates, the test fakes stub it.evaluate.ccContentToSearch(type-gate + read + binary sniff) +EvalContent/EvalRxc.CompileNodeRegexprecompiles-rxc/-irxclike-regex/-iregex.Self-documentation (registry SOT, same change)
Four
Descriptorsummaries flow into--help/--help=NAME/--man/--markdown; thekHelpTextexpression summary is updated;docs/design.mdrecords the resolved names, superseding the-contains/-grepplaceholders.Tests
regex_test:PartialMatch(unanchored vsFullMatch).local_fs_test:ReadContentbytes + missing-path error.evaluate_test: literal / regex / case-fold / binary-skip / non-regular + missing.content_test.sh: end-to-end through the binary, incl. find-style gating and the--help=-contenttopic.bazel test //...green (29 tests).