Expand description
Bundled commands: utilities that ship inside the brush binary.
Utilities are shipped busybox-style (one binary, many names) but execute as a subprocess of brush so that shell redirections, pipes, and process-group state are honored by code that reads/writes the host process’s standard fds (e.g., uutils crates).
§Protocol
The brush binary recognizes a hidden first-position argument
DISPATCH_FLAG followed by <NAME> [ARGS...]. When present, brush
dispatches early in main() to the registered function for NAME, before
any shell state is built, and exits with the function’s return code. The
dispatched function has the same signature as uutils’ uumain:
fn(Vec<OsString>) -> i32, with the bundled name as argv[0].
§Shell integration
For every entry in the registry, register_shims installs a brush
builtin (using register_builtin_if_unset, so brush’s own builtins always
win on conflict). The builtin’s execution path uses brush-core’s existing
external-command machinery to spawn current_exe() <DISPATCH_FLAG> <name> <args...>, inheriting the shell’s redirection state for free.
The mechanism is generic — the registry is just name → fn pointer. The
experimental-bundled-coreutils feature populates it with uutils, but
anything matching the signature can be registered.
Constants§
- DISPATCH_
FLAG - The leading flag that signals a bundled-command dispatch.
Functions§
- install
- Installs the bundled-command registry. Idempotent: only the first call takes effect.
- install_
default_ providers - Installs the registry from all compiled-in providers.
- maybe_
dispatch - Runs the bundled-command fast path if the process was invoked for it.
- register_
shims - Registers a shim builtin for every name in the installed bundled-command registry.
- registry
- Returns the registered bundled commands, if
installwas called.
Type Aliases§
- Bundled
Fn - Signature of a bundled command’s entry point — matches
uu_*::uumain.