feat(coreutils): add grep, find and xargs - #441
Open
raphaelvigee wants to merge 1 commit into
Open
Conversation
raphaelvigee
commented
Aug 29, 2026
Member
Three of the largest remaining divergences. `grep -P` does not exist on
macOS; `find`'s `-printf`, `-regextype`, `-delete` and `-newermt` are all
GNU-only and BSD `find` requires an explicit path; and `xargs -r` is
GNU-only while the no-input default is inverted between the two.
`find` and `xargs` are adapters over uutils/findutils. Its entry points
take `&[&str]`, so a non-UTF-8 argument is refused by name rather than
lossily converted: GNU `find` accepts arbitrary bytes in a path, this
cannot, and searching a *different* path than the one asked for is worse
than saying so.
`grep` is a POSIX front-end over `grep-searcher`/`grep-regex`, the engine
ripgrep uses, covering -EFivnclLqwxrhHs, -m, -e, -f and `--`. Two
deliberate departures from GNU:
- No -P. The `regex` crate has no backreferences or lookaround by
design, so -P fails with that explanation rather than with "invalid
option" — a pattern needing it has to be rewritten, not retried.
- Never colourised. Output goes into build logs and gets parsed; a
`--color=auto` that guessed from a tty would make a recipe's
behaviour depend on how it was invoked.
The argument parser is hand-rolled rather than clap because `grep -e -v
file` must treat `-v` as the pattern, which a declarative parser fights.
Line numbers are always counted and only printed under -n: the `UTF8`
sink asks every match for its line number and fails with "line numbers
not enabled" if the searcher was not tracking them — found by running it.
Not planned: `diff`/`cmp`. The `diffutils` crate exposes its algorithms
but keeps its CLI in a private `main`, so wiring it up would mean
reimplementing its argument parsing for the lowest-value pair in the set.
Verified against the host's GNU tools: `find . -name '*.txt'` and
`grep -c`/`grep -v` produce byte-identical output, `find -printf` works
(GNU-only), and `find | xargs` pipelines. `heph tool coreutils list` no
longer errors when piped into `head`.
COREUTILS_VERSION 1 -> 2: the applet set changed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0181d7hhbYWXT42Z1KQPM29Q
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.