Expand description
§Rash - Rust to Shell Transpiler
Rash is a Rust-to-POSIX shell script transpiler that generates safe, deterministic, and verifiable shell scripts from a restricted Rust subset.
§Features
- POSIX Compliance: Generated scripts work on sh, dash, bash, and ash
- Safety: Injection attack prevention, proper quoting, verified output
- Determinism: Same input always produces identical output
- ShellCheck Integration: All output passes shellcheck validation
§Quick Start
use bashrs::{transpile, Config};
let rust_code = r#"
fn main() {
let greeting = "Hello, World!";
echo(greeting);
}
fn echo(msg: &str) {}
"#;
let shell_script = transpile(rust_code, Config::default()).unwrap();
assert!(shell_script.contains("#!/bin/sh"));§Main Functions
§Configuration
use bashrs::{Config, transpile};
use bashrs::models::{ShellDialect, VerificationLevel};
let config = Config {
target: ShellDialect::Posix,
verify: VerificationLevel::Strict,
optimize: true,
..Config::default()
};
let rust_code = "fn main() { let x = 42; }";
let result = transpile(rust_code, config);
assert!(result.is_ok());Re-exports§
pub use models::Config;pub use models::Error;pub use models::Result;pub use transpiler::Transpiler;
Modules§
- ast
- Abstract syntax tree types and validation
- bash_
parser - Bash script parsing and AST generation Bash-to-Rash Parser Module
- bash_
quality - Bash quality tools (test generation, coverage, formatting, scoring) Bash Quality Tools
- bash_
transpiler - Bash script transpilation and purification Bash-to-Rash Transpiler
- build_
rs - build.rs integration with auto-discovery
- cli
- Command-line interface for bashrs
- compiler
- Rust compiler integration for transpilation Compiler module for bashrs
- config
- Shell configuration file management and analysis Shell configuration file management
- container
- Container and sandbox support
- emitter
- Shell script code emission
- formal
- Formal verification and proof generation Formal verification module for the rash emitter
- formatter
- Shell script formatting Pre-flight Formatter Implementation
- ir
- Intermediate representation for transpilation Intermediate Representation (IR) module
- linter
- Shell script linting with ShellCheck-equivalent rules bashrs Native Linter
- make_
parser - Makefile parsing and purification
- models
- Configuration types and error handling
- repl
- Interactive REPL with integrated debugger
- services
- Parser and compiler services
- stdlib
- Standard library function mappings
- test_
generator - Test case generation from shell scripts Test Generation Module
- tracing
- Tracing infrastructure for diagnostics and debugging
- transpiler
- Builder API for programmatic transpilation
- types
- Type system with taint tracking for injection safety Type system for bashrs
- validation
- AST and output validation
- verifier
- Output verification and shellcheck integration