Rash - Bidirectional Shell Safety Tool
Rash (v6.22.0) is a bidirectional shell safety tool that purifies legacy bash scripts and lets you write shell scripts in REAL Rust with automatic safety guarantees.
๐ What's New in v6.22.0
REPL Debugging Enhancements - Released 2025-10-30
- Call Stack Tracking: Track function call hierarchy with
StackFramestructs - Purification-Aware Debugging: Compare original vs purified bash at breakpoints in real-time
- Interactive Development: See how bashrs transforms your scripts during debugging
See CHANGELOG.md for complete release notes.
Why Rash?
- ๐ก๏ธ Automatic Safety: Protection against shell injection, word splitting, glob expansion
- ๐ Beyond Linting: Full AST semantic understanding - transforms code, doesn't just warn
- ๐ฆ Zero Runtime Dependencies: Generated scripts work on any POSIX shell
- ๐ฏ Deterministic Output: Same input always produces identical scripts
- โ ShellCheck Compliant: All output passes strict linting
How Rash Exceeds ShellCheck
| What ShellCheck Does | What Rash Does |
|---|---|
| โ ๏ธ Warns: "$RANDOM is non-deterministic" | โ Rewrites to version-based deterministic IDs |
| โ ๏ธ Warns: "mkdir may fail if exists" | โ
Transforms to mkdir -p (idempotent) |
| โ ๏ธ Warns: "Unquoted variable expansion" | โ Quotes all variables automatically |
| Static pattern matching | Full AST semantic understanding |
| Detects issues (read-only) | Fixes issues (read-write transformation) |
Key Difference: ShellCheck tells you what's wrong. Rash understands your code's intent and rewrites it to be safe, deterministic, and idempotent โ automatically.
Quick Start
Installation
# From crates.io (recommended)
# Or from source
Write Rust, Get Safe Shell
// install.rs
Transpile to safe POSIX shell:
Or Purify Existing Bash
Before (messy bash):
#!/bin/bash
SESSION_ID= # Non-deterministic
After (purified by Rash):
#!/bin/sh
session_id="session-" # โ
Deterministic
Core Commands
# Transpile Rust to shell
# Purify legacy bash scripts
# Interactive REPL with debugging
# Lint shell scripts
# Test bash scripts
# Quality scoring
# Comprehensive audit
๐ Documentation
The Rash Book is the canonical source for all documentation:
โ Read The Rash Book
Quick links:
Why the book?
- โ All examples automatically tested
- โ Always up-to-date with latest release
- โ Comprehensive coverage of all features
- โ Real-world examples and tutorials
Quality Metrics (v6.22.0)
| Metric | Status |
|---|---|
| Quality Grade | A+ (Near Perfect) โ |
| Tests | 5,465 passing (0 failures) โ |
| Coverage | 88.71% (exceeds 85% target) โ |
| Mutation Testing | 92% kill rate โ |
| Property Tests | 52 properties (~26k+ cases) โ |
| ShellCheck | 100% compliant โ |
| Shell Compatibility | sh, dash, bash, ash, zsh, mksh โ |
Shell Compatibility
Generated scripts are tested on:
| Shell | Version | Status |
|---|---|---|
| POSIX sh | - | โ Full support |
| dash | 0.5.11+ | โ Full support |
| bash | 3.2+ | โ Full support |
| ash (BusyBox) | 1.30+ | โ Full support |
| zsh | 5.0+ | โ Full support |
| mksh | R59+ | โ Full support |
Performance
Rash is designed for fast transpilation:
- Rust-to-Shell: 21.1ยตs transpile time
- Makefile Parsing: 0.034-1.43ms (70-320x faster than targets)
- Memory Usage: <10MB for most scripts
MCP Server
Rash provides a Model Context Protocol (MCP) server for AI-assisted shell script generation:
# Install MCP server
# Run server
Available in the official MCP registry as io.github.paiml/rash.
Contributing
We welcome contributions! See our Contributing Guide for details.
# Clone and test
# Run all quality checks
License
Rash is licensed under the MIT License. See LICENSE for details.
Acknowledgments
Rash is built with safety principles inspired by:
- ShellCheck for shell script analysis
- Oil Shell for shell language design
- The Rust community for memory safety practices
For comprehensive documentation, tutorials, and examples, visit The Rash Book.