#[non_exhaustive]pub enum Expr {
Show 20 variants
Literal(Value),
VarRef(VarPath),
Interpolated(Vec<StringPart>),
HereDocBody {
parts: Vec<SpannedPart>,
strip_tabs: bool,
},
Not(Box<Expr>),
BinaryOp {
left: Box<Expr>,
op: BinaryOp,
right: Box<Expr>,
},
CommandSubst(Vec<Stmt>),
Test(Box<TestExpr>),
Positional(usize),
AllArgs,
ArgCount,
VarLength(VarPath),
VarWithDefault {
path: VarPath,
default: Vec<StringPart>,
},
Arithmetic(String),
Command(Command),
LastExitCode,
CurrentPid,
GlobPattern(String),
ListLiteral(Vec<ListElem>),
RecordLiteral(Vec<RecordEntry>),
}Expand description
An expression that evaluates to a value.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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.
Not(Box<Expr>)
Negated condition: ! cmd, ! [[ … ]].
Binds to the command that follows, not to the whole &&/|| chain —
! true && true is (! true) && true, which is bash’s reading and
takes the else branch.
BinaryOp
Binary operation: a && b, a || b
CommandSubst(Vec<Stmt>)
Command substitution: $(...) — runs a statement block (the full grammar:
pipelines, &&/|| chains, ;/newline sequences, # comments) and
returns its accumulated stdout. A single $(cmd) is a one-statement block.
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(VarPath)
Variable string length: ${#VAR} or ${#path[sub]}
VarWithDefault
Variable with default: ${VAR:-default} / ${path[sub]:-default} — use
default if the path is absent (unset root, missing key, out-of-bounds) 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
ListLiteral(Vec<ListElem>)
List literal: [a b c], [], [...$xs date]. Value-position only
(assignment RHS, in/not in RHS, nested literal interiors) — never
argv or a for-head item. See docs/LANGUAGE.md, “Construction —
list/record literals”.
RecordLiteral(Vec<RecordEntry>)
Record literal: {name: amy, role: maintainer}, {port:8080} (colon
may be spaced or unspaced). Value-position only, same as ListLiteral.
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.