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§
Modules§
- ast
- Abstract Syntax Tree (AST) Module
- bash_
parser - Bash-to-Rash Parser Module
- bash_
quality - Bash Quality Tools
- bash_
transpiler - Bash-to-Rash Transpiler
- cli
- compiler
- Compiler module for bashrs
- config
- Shell configuration file management
- container
- emitter
- Shell Code Emitter Module
- formal
- Formal verification module for the rash emitter
- formatter
- Pre-flight Formatter Implementation
- ir
- Intermediate Representation (IR) module
- linter
- bashrs Native Linter
- make_
parser - Makefile Parser and Purification
- models
- repl
- services
- stdlib
- This module provides support for stdlib functions that are transpiled to POSIX shell runtime functions.
- test_
generator - Test Generation Module
- validation
- verifier