Skip to main content

Shell

Trait Shell 

Source
pub trait Shell: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn execute(
        &self,
        recipe: &str,
        env: &HashMap<String, String>,
        dir: &Path,
    ) -> Result<ShellResult, ShellError>;
    fn find_unescaped(&self, input: &str, ch: char) -> Vec<usize>;
    fn quote(&self, token: &str) -> String;
}
Expand description

Abstraction for executing recipe scripts. Implementations: sh (POSIX /bin/sh), rc (Plan 9 rc), duckscript (future).

Required Methods§

Source

fn name(&self) -> &str

Human-readable shell name (e.g. “sh”, “rc”).

Source

fn execute( &self, recipe: &str, env: &HashMap<String, String>, dir: &Path, ) -> Result<ShellResult, ShellError>

Execute a recipe script. recipe — the full script text (multiline string). env — environment variables to pass to the shell process. dir — working directory for the recipe.

Source

fn find_unescaped(&self, input: &str, ch: char) -> Vec<usize>

Find unescaped instances of a character in a string. Used by the parser to detect assignment attributes. E.g. find unescaped ‘=’ to separate attr from value.

Source

fn quote(&self, token: &str) -> String

Shell-quote a string so it’s safe as a shell argument.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§