pub enum Stmt {
Show 17 variants
Assignment(Assignment),
Command(Command),
Pipeline(Pipeline),
If(IfStmt),
For(ForLoop),
While(WhileLoop),
Case(CaseStmt),
Break(Option<usize>),
Continue(Option<usize>),
Return(Option<Box<Expr>>),
Exit(Option<Box<Expr>>),
ToolDef(ToolDef),
Test(TestExpr),
AndChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
OrChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
EnvScoped {
assignments: Vec<Assignment>,
body: Box<Stmt>,
},
Empty,
}Expand description
A single statement in kaish.
Variants§
Assignment(Assignment)
Variable assignment: NAME=value or local NAME = value
Command(Command)
Simple command: tool arg1 arg2
Pipeline(Pipeline)
Pipeline: a | b | c
If(IfStmt)
Conditional: if cond; then ...; fi
For(ForLoop)
Loop: for X in items; do ...; done
While(WhileLoop)
While loop: while cond; do ...; done
Case(CaseStmt)
Case statement: case expr in pattern) ... ;; esac
Break(Option<usize>)
Break out of loop: break or break N
Continue(Option<usize>)
Continue to next iteration: continue or continue N
Return(Option<Box<Expr>>)
Return from tool: return or return expr
Exit(Option<Box<Expr>>)
Exit the script: exit or exit code
ToolDef(ToolDef)
Tool definition: tool name(params) { body }
Test(TestExpr)
Test expression: [[ -f path ]] or [[ $X == "value" ]]
AndChain
Statement chain with &&: run right only if left succeeds
OrChain
Statement chain with ||: run right only if left fails
EnvScoped
Inline env prefix: NAME=value... command. The assignments are exported
for the duration of body only (bash-style command-scoped environment)
and do not persist after it — distinct from a plain Assignment, which
is persistent. body is always a command or pipeline.
Empty
Empty statement (newline or semicolon only)