ilsh - A POSIX-Compliant Shell (CLI) Implementation in Rust
Supported Builtin Commands
- cd - change the working directory
- echo [string...] - write arguments to standard output
- exit [n] - cause the shell to exit
- pwd - return working directory name
- type [type name...] - write a description of command type
Notes
- Mostly bash is used as a reference, but not everything is in accordance
with
bash. - Supports running external programs with arguments.
- External programs are located using the PATH environment variable.
- Supports single quotes.
- Supports double quotes.
- Supports escape character outside quotes.
- Supports redirecting output.
- Supports appending redirected output.
- Supports shell-specific
&>wordand shell-specific>&word, which redirect bothstdoutandstderrto the file whose name is the expansion ofword. - Supports multiple redirections.
Security
- cargo audit is supported, as well as its GitHub action, audit-check.
- cargo deny is supported, as well as its GitHub action, cargo-deny-action.
Development
Pre-commit
pre-commit hooks are supported.
$ pip install pre-commit # If you don't already have pre-commit installed on your machine. Run once.
$ pre-commit autoupdate # Update hook repositories to the latest versions.
$ pre-commit install # Sets up the pre-commit git hook script for the repository. Run once.
$ pre-commit install --hook-type pre-push # Sets up the pre-push git hook script for the repository. Run once.
$ pre-commit run # For manual running; considers only modified files.
$ pre-commit run --all-files # For manual running; considers all files.
After installing it, the provided pre-commit hook(s) will run automatically on git commit.
Running the Program
cargo run --release
export DEBUG=false
cargo run --release
A run script is provided.
The run script can set the DEBUG environment variable to false or true.
./run.sh
Building and Running the Program with Debug Output
The program supports debugging output, which can be enabled by setting
the environment variable DEBUG to the value true.
It can be set outside the program, in the user shell, or inside the run.sh shell script.
This is only considered during compile time, and not during run time.
DEBUG=true ./run.sh
export DEBUG=true
./run.sh
Testing
- Unit-test with
cargo test. - End-to-end-test with
./test.sh.