Expand description
A portable implementation of Bun Shell (Bun.$), ported from Bun’s
src/runtime/shell and src/shell_parser and kept behaviour-identical
with the JavaScript port in js/src/bun-shell/.
Scripts are written as template literals: strings are the raw template
parts and values the interpolated values between them, exactly like
$`echo ${name} | cat` in JavaScript:
use command_stream::bun_shell::{shell, ShellValue};
let out = shell(&["echo ", " | cat"], vec![ShellValue::from("world")])?
.quiet()
.run()
.await?;
assert_eq!(out.text(), "world\n");The conformance corpus in conformance/bun-shell/ is the specification;
rust/tests/bun_shell_conformance.rs runs it against this module.
Structs§
- OutBuffer
- A fixed-size byte buffer that receives output (
> ${buf}in JavaScript, wherebufis aUint8Array). Output beyond its size is dropped. - Shell
- Default settings for new commands (Bun’s
new $.Shell()): eachShellhas its own cwd, env and throwing mode. - Shell
Command - A parsed script plus its settings (Bun’s
ShellPromise). Nothing runs untilShellCommand::runis awaited. - Shell
Error - A failed shell invocation.
- Shell
Output - The result of a finished script (Bun’s
ShellOutput).
Enums§
- Brace
Error - A brace expansion failure.
- Shell
Error Kind - What kind of failure a
ShellErroris. - Shell
Value - An interpolated template value (the JavaScript value kinds that Bun Shell
accepts, minus the JS-only
Response/Blob/Bun.fileobjects).