feat: add optional bundling of coreutils builtins behind experimental feature flag#1031
Conversation
Public API changes for crate: brush-coreAdded itemsPublic API changes for crate: brush-shellAdded itemsPerformance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
|
Very cool! Thanks for putting this together 😄 With all these commands present, how well does the shell seem to work on Windows? (I'm assuming from your output above that's where you've tested this?) I skimmed through the changes and they look quite reasonable. (I wish there were a way to dynamically get the command short-description from I've thought about it a bit more since and one thing we'll need to keep in mind is that much of With that said, this seems interesting to enough to keep pursuing. I'm inclined to bring these in under an "experimental" qualifier, as we've done with some of the other speculative features/extensions. (That just might entail prefixing the feature in |
|
I created a minimal Azure Linux Dockerfile to try it out and it works well. |
|
@cataggar I'd like to move toward getting this PR merged but would like to qualify the coreutils integration as "experimental" -- particularly because of known challenges with stdio redirection. Are you up for making some adjustments? Alternatively, I'm open to making some of the adjustments myself if you're okay with me pushing changes to your PR branch. In particular here are the items that we'll need to sort out:
|
|
You should exclude |
@oech3 can you share more about what you're thinking here? Or a concrete example? |
|
https://github.com/uutils/coreutils/blob/de5e4f54f224a25875bdc207cd57f035a58fbe0a/Cargo.toml#L174-L225 |
|
uutils has policy to avoid |
Yes, I'd expect it would. It's for reasons like this that I'd consider this integration experimental. The input/output redirection issues I mention above are another class of challenges. |
|
I'm the author of There's been a longstanding desire to embed a shell and common utilities in The combination of brush and There are definitely potential issues. The binary would be absolutely gargantuan, and Anyways, just wanted to say that I think this is a super cool direction to explore, and I'm very interested in how things develop. |
Thanks for reaching out, @casey! (Big fan of I'm also interested in the idea of a(n emeddable?) variant build of Do you have a point of view on which shell functionality / common utilities you and your users would want to see |
I think it makes sense for those to be different binaries.
If it was embedded in Then you would just do: In your justfile, or whatever the command line would be. |
|
Oh, and sorry, I didn't fully answer this question:
I'm not actually sure about which utilities users would want. I think there are probably some obscure ones that don't get used frequently, but I'm not sure how to think of the tradeoff between a larger binary with all utilities, and a smaller binary without some obscure utilities. |
|
Can we bind uutils/date to #677 ? |
| #[allow(clippy::too_many_lines)] | ||
| pub fn coreutils_builtins<SE: brush_core::extensions::ShellExtensions>() | ||
| -> HashMap<String, builtins::Registration<SE>> { | ||
| let mut m = HashMap::<String, builtins::Registration<SE>>::new(); |
There was a problem hiding this comment.
| let mut m = HashMap::<String, builtins::Registration<SE>>::new(); | |
| let mut m = HashMap::<&'static str, builtins::Registration<SE>>::new(); |
Is there no reason this could be used?
Experimenting with an approach that allows bundling commands within single hosting binary and registers them as builtins -- but runs the real code out-of-process to create a boundary at which `brush` will reflect state (e.g., fds, env vars, etc.) back to the process's OS state. Without this, there's a risk that the coreutils commands would write directly to, for example, std::io::stdout -- which would sidestep any redirection in the shell. Assisted-by: Claude Opus 4.7
4db4716 to
148360f
Compare
Plain `cargo build --workspace` previously compiled ~80 uu_* crates because brush-coreutils-builtins enabled `coreutils.all` by default. Flip the crate's default to `[]` so the scaffolding builds in ~14s instead of paying the uu_* compile cost on every workspace build. brush-shell's `experimental-bundled-coreutils` now pulls in `brush-coreutils-builtins/coreutils.all` so the experimental opt-in shape is unchanged for consumers. `cargo xtask ci pre-commit` (via `cargo check/clippy --all-features --workspace`) still exercises the full uu_* surface, so the experimental wiring is covered.
This is a first pass at adding the coreutils as builtins per the suggestion #990 (comment) .
cargo install --locked brush-shell --features coreutils-builtins