Skip to main content

Crate epsh

Crate epsh 

Source
Expand description

§epsh — Embeddable POSIX Shell

A non-interactive POSIX shell designed for embedding in Rust coding agents. Executes scripts and commands in-process with full control over working directory, output capture, cancellation, and timeouts.

§Quick start

use epsh::eval::Shell;

let mut shell = Shell::new();
let exit_code = shell.run_script("echo hello world");

§Builder pattern

use epsh::eval::Shell;
use std::sync::{Arc, Mutex};
use std::path::PathBuf;
use std::time::Duration;

let stdout = Arc::new(Mutex::new(Vec::<u8>::new()));
let mut shell = Shell::builder()
    .cwd(PathBuf::from("/project"))
    .errexit(true)
    .stdout_sink(stdout.clone())
    .timeout(Duration::from_secs(120))
    .build();

Modules§

arith
Arithmetic expression evaluator for $((expr)). Arithmetic expression evaluator for $((expr)).
ast
AST types: ast::Command, ast::Word, ast::WordPart, etc.
builtins
Shell builtins and builtins::BUILTIN_NAMES.
encoding
Byte-preserving encoding for non-UTF-8 shell data. Byte-preserving encoding for non-UTF-8 shell data.
error
Error types: error::ShellError, error::ExitStatus.
eval
Shell interpreter: eval::Shell, eval::ShellBuilder.
expand
Word expansion: tilde, parameter, arithmetic, field splitting, globbing.
glob
Glob pattern matching and pathname expansion.
lexer
Lexer/tokenizer.
parser
Recursive-descent parser producing ast::Program.
shell_bytes
Byte-preserving shell runtime values and OS/libc conversion helpers.
var
Variable storage with scope stack.