pub fn execute(ast: Ast, shell_state: &mut ShellState) -> i32Expand description
Evaluate an AST node within the provided shell state and return its exit code.
Executes the given ast, updating shell_state (variables, loop/function/subshell state,
file descriptor and redirection effects, traps, etc.) as the AST semantics require.
The function returns the final exit code for the executed AST node (0 for success,
non-zero for failure). Side effects on shell_state follow the shell semantics
implemented by the executor (variable assignment, function definition/call, loops,
pipelines, redirections, subshell isolation, errexit behavior, traps, etc.).
ยงExamples
use rush_sh::{Ast, ShellState};
use rush_sh::executor::execute;
let mut state = ShellState::new();
let ast = Ast::Assignment { var: "X".into(), value: "1".into() };
let code = execute(ast, &mut state);
assert_eq!(code, 0);
assert_eq!(state.get_var("X").as_deref(), Some("1"));