pub enum Expr {
Show 17 variants
Literal(Value),
VarRef(VarPath),
Interpolated(Vec<StringPart>),
HereDocBody {
parts: Vec<SpannedPart>,
strip_tabs: bool,
},
BinaryOp {
left: Box<Expr>,
op: BinaryOp,
right: Box<Expr>,
},
CommandSubst(Box<Pipeline>),
Test(Box<TestExpr>),
Positional(usize),
AllArgs,
ArgCount,
VarLength(String),
VarWithDefault {
name: String,
default: Vec<StringPart>,
},
Arithmetic(String),
Command(Command),
LastExitCode,
CurrentPid,
GlobPattern(String),
}Expand description
An expression that evaluates to a value.
Variants§
Literal(Value)
Literal value
VarRef(VarPath)
Variable reference: ${VAR} or ${VAR.field} or $VAR
Interpolated(Vec<StringPart>)
String with interpolation: "hello ${NAME}" or "hello $NAME"
HereDocBody
Interpolated heredoc body with per-part spans for diagnostic precision.
Heredoc bodies use this variant; double-quoted strings still use
Interpolated to keep the existing path untouched. strip_tabs is
true for the <<-EOF form — leading tabs on each body line are
stripped from StringPart::Literal content at materialization time
(POSIX semantics); offsets in parts reference the verbatim source
so spans remain meaningful.
BinaryOp
Binary operation: a && b, a || b
CommandSubst(Box<Pipeline>)
Command substitution: $(pipeline) - runs a pipeline and returns its result
Test(Box<TestExpr>)
Test expression: [[ -f path ]] or [[ $X == "value" ]]
Positional(usize)
Positional parameter: $0 through $9
AllArgs
All positional arguments: $@
ArgCount
Argument count: $#
VarLength(String)
Variable string length: ${#VAR}
VarWithDefault
Variable with default: ${VAR:-default} - use default if VAR is unset or empty
The default can contain nested variable expansions and command substitutions
Arithmetic(String)
Arithmetic expansion: $((expr)) - evaluates to integer
Command(Command)
Command as condition: if grep -q pattern file; then - exit code determines truthiness
LastExitCode
Last exit code: $?
CurrentPid
Current shell PID: $$
GlobPattern(String)
Bare glob pattern: *.txt, src/**/*.rs — expanded during arg building