A POSIX-compliant shell implementation written in Rust, built from the ground up against the POSIX.1-2017 shell grammar.
Work in progress. The following are implemented:
- Lexer with full operator and reserved word recognition
- Recursive descent parser covering the complete POSIX shell grammar
- AST pretty-printer
cargo build
./target/debug/posix-shell-rust -p -c 'echo hello world'
./target/debug/posix-shell-rust --pretty-printer -c 'echo hello world' # string
./target/debug/posix-shell-rust -p file.txt # file
./target/debug/posix-shell-rust -p # standard inputIt is recommended to use single quotes when using string as input so your own shell won't interact with the input.
| Flag | Description |
|---|---|
-c <string> |
Execute a command string |
-p or --pretty-print |
Print the parsed AST instead of executing |
src/ ├── ast/ # AST definitions │ └── pretty_print/ # AST pretty-printer ├── lexer/ # Tokenization ├── parser/ # Recursive descent parser ├── exec/ # Execution engine (WIP) │ └── builtin/ # Built-in commands ├── io_backend/ # Input handling (stdin, files, etc.) ├── variables/ # Shell variables & environment └── main.rs # Entry point
MIT — see LICENSE.