pub enum Expr {
Show 15 variants
Literal(Value),
VarRef(VarPath),
Interpolated(Vec<StringPart>),
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,
}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"
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: $$
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 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> 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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more