2 unstable releases
0.2.0 | Apr 14, 2021 |
---|---|
0.1.0 | Nov 18, 2018 |
#13 in #dash
36KB
776 lines
rash - the Rust Bourne Shell
A bourne shell inspired by dash.
Goals
These goals guide design decisions and the feature roadmap. Once the shell is complete, we can look at more ambitious goals like implementing features beyond POSIX, extending the programming language, and more aggressive speed optimizations.
The guiding goals include:
- A high level of POSIX compliance
- Helpful error messages
- Modern terminal interface features
- Fast
- Secure by default (even when it means violating POSIX)
Design
The overall design is inspired by the dash shell which is the default
/bin/sh
on Debian and Ubuntu. It has a long lineage dating back to
early bourne shells.
Dash was built for speed, POSIX compliance, and a small codebase. It's a great source of design wisdom and serves as a good reference implementation when the POSIX spec is unclear.
Rash's parser and evaluator take inspiration from dash. Rash uses a parser generator called LALRPOP to generate an AST. It then walks the AST evaluating statements. The grammar and AST are based on the grammar and terminology defined by POSIX which makes it easy to use the standard as a reference for understanding rash.
Contributions
Contributions are welcomed! The status list below is a great place to find a feature to implement. If the codebase looks too complicated at first, there are several features that don't require changing much existing code.
Open a GitHub Issue for questions, requests, or patches.
The project is licensed under the Apache License 2.0.
Status
With the exception of the most obscure features, syntax and functionality are either fully implemented or not at all. This means that you can be confident when using the features marked as complete below. Any errors or omissions in existing functionality are bugs and may be treated as such.
Features:
- executing commands
- pipelines
- boolean logic
- async execution (
&
) - path searching
- variable interpolation
- environment manipulation (export, unset, readonly, variable prefixes)
- cd
- saving the exit status (
$?
) - subshells
- interpolating $() and backticks
- eval quotes, single quotes
- I/O Redirection
- job control
- shell startup arguments (e.g.
-c
,-l
) -
set
command - control flow operators (
if
,while
,case
)
Interactive Mode:
- history (not yet configurable or persistent)
- keybindings (not yet configurable)
- configurable settings
- tab completion
Quality Improvements:
- Compliance test suite
- See osh tests
- consistent error message format
- Path hashing
- Other common performance optimizations
References
Relevant Rust Language Information
Dependencies
~6–15MB
~193K SLoC