Files
ripgrep/crates/core
Andrew Gallant afc820c9e9 cli: make rg -vf file behave sensibly
Previously, when `file` is empty (literally empty, as in, zero byte),
`rg -f file` and `rg -vf file` would behave identically. This is odd
and also doesn't match how GNU grep behaves. It's also not logically
correct. An empty file means _zero_ patterns which is an empty set. An
empty set matches nothing. Inverting the empty set should result in
matching everything.

This was because of an errant optimization that lets ripgrep quit early
if it can statically detect that no matches are possible.

Moreover, there was *also* a bug in how we constructed the PCRE2 pattern
when there are zero patterns. PCRE2 doesn't have a concept of sets of
patterns (unlike the `regex` crate), so we need to fake it with an empty
character class.

Fixes #1332, Fixes #3001, Closes #3041
2025-07-27 15:09:19 -04:00
..
2024-03-07 09:37:48 -05:00
2025-07-26 11:41:17 -04:00
2025-07-26 11:52:49 -04:00

ripgrep core

This is the core ripgrep crate. In particular, main.rs is where the main function lives.

Most of ripgrep core consists of two things:

  • The definition of the CLI interface, including docs for every flag.
  • Glue code that brings the grep-matcher, grep-regex, grep-searcher and grep-printer crates together to actually execute the search.

Currently, there are no plans to make ripgrep core available as an independent library. However, much of the heavy lifting of ripgrep is done via its constituent crates, which can be reused independent of ripgrep. Unfortunately, there is no guide or tutorial to teach folks how to do this yet.