Rash - Bidirectional Shell Safety Tool
Rash (v6.34.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.34.0+
Latest Updates - 2025-11-12
- Issue #21 FIXED: SC2171 false positive with JSON brackets in heredocs (now correctly handles heredoc contexts)
- Issue #22 FIXED: SC2247 false positive with math operations in awk/bc (context-aware math detection)
- Test Suite: 6,583 tests, 100% pass rate, zero regressions
- Quality: All fixes implemented using EXTREME TDD (unit tests, property tests, mutation tests, integration tests)
v6.34.0 Feature Completions - Released 2025-11-12
- Issue #2 RESOLVED: Makefile multi-line format preservation with
--preserve-formattingand--skip-consolidationflags - Issue #4 RESOLVED: Complete bash parser - all 9 phases including redirection operators, heredocs, pipelines, special variables
- Dockerfile Purification: 6 comprehensive transformations (DOCKER001-006) for production-ready Docker images
- Dogfooding Complete: Fixed all P0 errors in bashrs's own infrastructure (0 errors found by self-analysis)
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.36.0+)
| Metric | Status |
|---|---|
| Quality Grade | A+ (Near Perfect) โ |
| Tests | 6,583 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 โ |
| Golden Traces | Renacer integration for regression detection โ |
Golden Trace Regression Detection (v6.36.0+)
Rash integrates with renacer to capture and compare syscall patterns for regression detection:
# Capture reference trace
# Compare against golden (detect regressions)
Use cases:
- Detect unexpected file access patterns
- Prevent security regressions
- Verify performance optimizations reduce syscalls
- Ensure deterministic behavior across builds
See Golden Trace Documentation for complete guide.
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.