https://github.com/zen-zap/rune
A minimal shell written in Rust
https://github.com/zen-zap/rune
rust shell
Last synced: 2 months ago
JSON representation
A minimal shell written in Rust
- Host: GitHub
- URL: https://github.com/zen-zap/rune
- Owner: zen-zap
- License: unlicense
- Created: 2025-06-02T20:21:38.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-16T18:29:47.000Z (about 1 year ago)
- Last Synced: 2025-06-29T12:39:05.882Z (about 1 year ago)
- Topics: rust, shell
- Language: Rust
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rune
A custom Unix-like shell implemented in Rust.
---
## Features
### Command Execution
- **External Commands:** Runs any executable available in `rune.conf` (e.g., `ls`, `grep`, `cat`).
- **Built-ins:** Supports standard built-in commands:
- `cd [dir]` — Change directory
- `pwd` — Print current working directory
- `echo` — Display some message
- `exit [code]` — Exit the shell with an optional status code
### Pipelines
- **Pipeline Processing:** Supports chaining commands with `|`, e.g.:
```sh
ls | grep src | wc
```
Each stage runs in its own process, with standard input/output properly connected via pipes.
### Miscellaneous
- **Process Groups:** Each pipeline sets up a process group for future job control features (`setpgid`), laying the groundwork for `Ctrl+Z`, backgrounding, and job management.
- **Proper FD Handling:** Pipes, stdin/stdout redirection, and close-on-exec all handled robustly to avoid resource leaks and deadlocks.
## Build and Run Instructions
### 1. **Prerequisites**
- [Rust](https://www.rust-lang.org/tools/install) (latest stable recommended)
- Unix-like OS (Linux, macOS, WSL, etc.)
### 2. **Clone the Repository**
```sh
git clone https://github.com/zen-zap/rune.git
cd rune
```
### 3. **Build**
```sh
cargo build
```
Or, for a development build with debug info:
```sh
cargo build --release
```
### 4. **Run**
```sh
cargo run
```
Or, run the compiled binary directly:
```sh
./target/debug/rune
# Or, for the release build:
./target/release/rune
```
### 5. **Usage Example**
```
RuneShell $ ls | grep src | wc
1 1 4
RuneShell $ cd ..
RuneShell $ pwd
/home/username
RuneShell $ exit
```
---
## Important!
It looks for a `rune.conf` file in `../rune` which is the parent directory of the rune directory, when you clone the repository.
Example Configuration:
```
/bin
/usr/bin
/usr/local/bin
/sbin
/usr/sbin
/home/username/.local/bin
./bin
```
Any contributions are welcome!