pub enum ParameterSubstitution<P, W, C, A> {
Command(Vec<C>),
Len(P),
Arith(Option<A>),
Default(bool, P, Option<W>),
Assign(bool, P, Option<W>),
Error(bool, P, Option<W>),
Alternative(bool, P, Option<W>),
RemoveSmallestSuffix(P, Option<W>),
RemoveLargestSuffix(P, Option<W>),
RemoveSmallestPrefix(P, Option<W>),
RemoveLargestPrefix(P, Option<W>),
}
Expand description
A parameter substitution, e.g. ${param-word}
.
Generic over the representations of parameters, shell words and commands, and arithmetic expansions.
Variants§
Command(Vec<C>)
Returns the standard output of running a command, e.g. $(cmd)
Len(P)
Returns the length of the value of a parameter, e.g. ${#param}
Arith(Option<A>)
Returns the resulting value of an arithmetic subsitution, e.g. $(( x++ ))
Default(bool, P, Option<W>)
Use a provided value if the parameter is null or unset, e.g.
${param:-[word]}
.
The boolean indicates the presence of a :
, and that if the parameter has
a null value, that situation should be treated as if the parameter is unset.
Assign(bool, P, Option<W>)
Assign a provided value to the parameter if it is null or unset,
e.g. ${param:=[word]}
.
The boolean indicates the presence of a :
, and that if the parameter has
a null value, that situation should be treated as if the parameter is unset.
Error(bool, P, Option<W>)
If the parameter is null or unset, an error should result with the provided
message, e.g. ${param:?[word]}
.
The boolean indicates the presence of a :
, and that if the parameter has
a null value, that situation should be treated as if the parameter is unset.
Alternative(bool, P, Option<W>)
If the parameter is NOT null or unset, a provided word will be used,
e.g. ${param:+[word]}
.
The boolean indicates the presence of a :
, and that if the parameter has
a null value, that situation should be treated as if the parameter is unset.
RemoveSmallestSuffix(P, Option<W>)
Remove smallest suffix pattern from a parameter’s value, e.g. ${param%pattern}
RemoveLargestSuffix(P, Option<W>)
Remove largest suffix pattern from a parameter’s value, e.g. ${param%%pattern}
RemoveSmallestPrefix(P, Option<W>)
Remove smallest prefix pattern from a parameter’s value, e.g. ${param#pattern}
RemoveLargestPrefix(P, Option<W>)
Remove largest prefix pattern from a parameter’s value, e.g. ${param##pattern}
Trait Implementations§
Source§impl<P: Clone, W: Clone, C: Clone, A: Clone> Clone for ParameterSubstitution<P, W, C, A>
impl<P: Clone, W: Clone, C: Clone, A: Clone> Clone for ParameterSubstitution<P, W, C, A>
Source§fn clone(&self) -> ParameterSubstitution<P, W, C, A>
fn clone(&self) -> ParameterSubstitution<P, W, C, A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<P: PartialEq, W: PartialEq, C: PartialEq, A: PartialEq> PartialEq for ParameterSubstitution<P, W, C, A>
impl<P: PartialEq, W: PartialEq, C: PartialEq, A: PartialEq> PartialEq for ParameterSubstitution<P, W, C, A>
Source§fn eq(&self, other: &ParameterSubstitution<P, W, C, A>) -> bool
fn eq(&self, other: &ParameterSubstitution<P, W, C, A>) -> bool
self
and other
values to be equal, and is used by ==
.