13 releases
new 0.2.13 | Nov 26, 2024 |
---|---|
0.2.12 | Nov 3, 2024 |
0.2.11 | Oct 18, 2024 |
0.2.10 | Sep 30, 2024 |
0.1.0 | Jun 11, 2024 |
#242 in Development tools
201 downloads per month
Used in 2 crates
1MB
18K
SLoC
brush
About
brush
(Bo(u)rn(e) RUsty SHell) is a POSIX- and bash-compatible shell,
implemented in Rust. It's built and tested on Linux and macOS, with experimental support on Windows. (Its Linux build is fully supported running on Windows via WSL.)
brush
is functional for interactive use as a daily driver! It can execute most sh
and bash
scripts we've
encountered. Known limitations are tracked with filed issues. Out of an abundance of caution,
we wouldn't recommend using it yet in production scenarios in case it doesn't behave identically
to your existing stable shell. (If you do find any behavioral differences, though, please report them with an
issue!)
Contributions and feedback of all kinds are welcome! For more guidance, please consult our contribution guidelines. For more technical details, please consult the documentation in this repo.
This project was originally borne out of curiosity and a desire to learn. We're doing our best to keep that attitude :).
License
Available for use and distribution under the MIT license.
Try it out!
We don't publish binary releases of brush
, but if you have a working rust
toolchain installed you can simply run:
cargo install --locked brush-shell
This will install the most recently released version of brush
from crates.io
. Alternatively, for the latest and
greatest bits, you can clone this repo and execute cargo run
.
If you don't have rust
installed, we recommend installing it via rustup
.
(If you are interested in having a binary release, then please let us know in the 'Discussions' area of this project or by filing a feature request in 'Issues'.)
When you run brush
, it should look exactly as bash
would on your system since it processes .bashrc
and
other usual configuration. If you'd like to customize the look of brush
to distinguish it from the other shells
installed on your system, then you can also author a ~/.brushrc
file.
Known limitations
There are some known gaps in compatibility. Most notably:
- Honoring
set
andshopt
options (e.g.,set -e
). Theset
builtin is implemented, as isset -x
and a few other options, but most of the options aren't fully implemented.set -e
, for example, will execute but its semantics aren't applied across execution. - Curly brace expansion.
Almost all forms of expansion are implemented; for some reason, we never got around to implementing an expansion that turns
{a,b}
intoa b
. There's even a test for this, but it's marked as a known failing test. - Anything tagged with a
TODO
comment or whereerror::unimp()
is used to return a "not implemented" error. These aren't all tracked with GitHub issues right now, but there's a number of these scattered throughout the code base. Some are indicative of missing functionality that may be straightforward to implement; others may be more complicated.
If you feel so inclined, we'd love contributions toward any of the above, with broadening test coverage, deeper compatibility evaluation, or really any other opportunities you can find to help make this project better.
Testing strategy
This project is primarily tested by comparing its behavior with other existing shells, leveraging the latter as test oracles. The integration tests implemented in this repo include 300+ test cases run on both this shell and an oracle, comparing standard output and exit codes.
For more details, please consult the reference documentation on integration testing.
Credits
There's a long list of OSS crates whose shoulders this project rests on. Notably, the following crates are directly relied on for major portions of shell functionality:
reedline
- for readline-like input and interactive usageclap
- command-line parsing, used both by the top-level brush CLI as well as built-in commandsfancy-regex
- relied on for everything regextokio
- async, well, everythingnix
rust crate - higher-level APIs for Unix/POSIX system APIs
Huge kudos and thanks also to pprof
and criterion
projects for enabling awesome flamegraphs in smooth integration with cargo bench
's standard benchmarking facilities.
Links: other shell implementations
There are a number of other POSIX-ish shells implemented in a non-C/C++ implementation language. Some inspirational examples include:
- Nushell - modern Rust-implemented shell (which also provides the
reedline
crate we use!) - Rusty Bash
- mvdan/sh
We're sure there are plenty more; we're happy to include links to them as well.
Dependencies
~12–43MB
~688K SLoC