Skip to main content

BashExpr

Enum BashExpr 

Source
pub enum BashExpr {
Show 25 variants Var(BashVar), Lit(String), DQuoted(String), CmdSubst(String), ArithExpr(String), ProcSubst { is_input: bool, cmd: String, }, ArrayElem(String, Box<BashExpr>), ArrayLen(String), ArrayAll(String), AssocElem(String, Box<BashExpr>), Default(String, Box<BashExpr>), AssignDefault(String, Box<BashExpr>), Substring(String, usize, Option<usize>), StringLen(String), StripPrefix(String, String), StripSuffix(String, String), UpperCase(String), LowerCase(String), LastStatus, ShellPid, ScriptName, Positional(usize), AllArgs, ArgCount, Concat(Box<BashExpr>, Box<BashExpr>),
}
Expand description

Bash expression / expansion node.

Variants§

§

Var(BashVar)

Variable expansion: ${name} or $name

§

Lit(String)

String literal (single-quoted, no expansion): 'hello'

§

DQuoted(String)

Double-quoted string (allows expansions): "hello $world"

§

CmdSubst(String)

Command substitution: $(cmd)

§

ArithExpr(String)

Arithmetic expansion: $(( expr ))

§

ProcSubst

Process substitution: <(cmd) or >(cmd)

Fields

§is_input: bool
§

ArrayElem(String, Box<BashExpr>)

Array element: ${arr[idx]}

§

ArrayLen(String)

Array length: ${#arr[@]}

§

ArrayAll(String)

All array elements: "${arr[@]}"

§

AssocElem(String, Box<BashExpr>)

Associative array element: ${map[$key]}

§

Default(String, Box<BashExpr>)

Parameter expansion with default: ${var:-default}

§

AssignDefault(String, Box<BashExpr>)

Parameter expansion with assign default: ${var:=default}

§

Substring(String, usize, Option<usize>)

Substring: ${var:offset:length}

§

StringLen(String)

String length: ${#var}

§

StripPrefix(String, String)

Pattern removal (prefix): ${var#pattern}

§

StripSuffix(String, String)

Pattern removal (suffix): ${var%pattern}

§

UpperCase(String)

Case conversion (Bash 4+): ${var^^} / ${var,,}

§

LowerCase(String)

§

LastStatus

Exit code of last command: $?

§

ShellPid

PID of current shell: $$

§

ScriptName

Script name: $0

§

Positional(usize)

Positional argument: $N

§

AllArgs

All positional arguments: "$@"

§

ArgCount

Number of positional arguments: $#

§

Concat(Box<BashExpr>, Box<BashExpr>)

Concatenation of two expressions

Trait Implementations§

Source§

impl Clone for BashExpr

Source§

fn clone(&self) -> BashExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BashExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for BashExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BashExpr

Source§

fn eq(&self, other: &BashExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BashExpr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.