pub enum ExpansionModifier<'a> {
Show 19 variants
Substring {
offset: Cow<'a, str>,
length: Option<Cow<'a, str>>,
},
StripShortestPrefix(Arc<BashPattern<'a>>),
StripLongestPrefix(Arc<BashPattern<'a>>),
StripShortestSuffix(Arc<BashPattern<'a>>),
StripLongestSuffix(Arc<BashPattern<'a>>),
ReplaceOnce {
pattern: Arc<BashPattern<'a>>,
string: Option<Arc<Text<'a>>>,
},
ReplaceAll {
pattern: Arc<BashPattern<'a>>,
string: Option<Arc<Text<'a>>>,
},
ReplacePrefix {
pattern: Arc<BashPattern<'a>>,
string: Option<Arc<Text<'a>>>,
},
ReplaceSuffix {
pattern: Arc<BashPattern<'a>>,
string: Option<Arc<Text<'a>>>,
},
UpperOnce(Arc<BashPattern<'a>>),
UpperAll(Arc<BashPattern<'a>>),
LowerOnce(Arc<BashPattern<'a>>),
LowerAll(Arc<BashPattern<'a>>),
ErrorOnUnset(Arc<Text<'a>>),
Length,
WhenUnset(Arc<Text<'a>>),
WhenSet(Arc<Text<'a>>),
ArrayElements,
SingleWordElements,
}Expand description
A modifier in the braced variable expansion.
Variants§
Substring
Reference to a substring (":offset" or ":offset:length").
The range is [offset, (offset+length)) (indexing from zero).
StripShortestPrefix(Arc<BashPattern<'a>>)
Stripping the shortest matching prefix ("#<pattern>").
StripLongestPrefix(Arc<BashPattern<'a>>)
Stripping the longest matching prefix ("##<pattern>").
StripShortestSuffix(Arc<BashPattern<'a>>)
Stripping the shortest matching suffix ("%<pattern>").
StripLongestSuffix(Arc<BashPattern<'a>>)
Stripping the longest matching suffix ("%%<pattern>").
ReplaceOnce
Replacing the first match of a pattern with a text ("/<pattern>[/<string>]").
string can be omitted, leaving "/<pattern>" structure,
which removes the first match of the pattern.
ReplaceAll
Replacing the all matches of a pattern with a text ("//<pattern>[/<string>]").
string can be omitted.
ReplacePrefix
Replacing the prefix of a pattern with a text ("/#<pattern>[/<string>]").
string can be omitted.
ReplaceSuffix
Replacing the suffix of a pattern with a text ("/%<pattern>[/<string>]").
string can be omitted.
UpperOnce(Arc<BashPattern<'a>>)
Upper-casify the first match of a pattern ("^<pattern>").
UpperAll(Arc<BashPattern<'a>>)
Upper-casify the all matches of a pattern ("^^<pattern>").
LowerOnce(Arc<BashPattern<'a>>)
Lower-casify the first match of a pattern (",<pattern>").
LowerAll(Arc<BashPattern<'a>>)
Lower-casify the all matches of a pattern (",,<pattern>").
ErrorOnUnset(Arc<Text<'a>>)
Producing errors when the variable is unset or null (":?<text>").
Length
Returning the length of the variable.
Note that this modifier uses a special format, see BracedExpansion.
WhenUnset(Arc<Text<'a>>)
Returning a text when the variable is unset or null (":-<text>").
WhenSet(Arc<Text<'a>>)
Returning a text when the variable is set (":+<text>").
ArrayElements
Expands to array elements ("[@]").
SingleWordElements
Expands to a string of array elements concatenated with space ("[*]").
Trait Implementations§
Source§impl<'a> Clone for ExpansionModifier<'a>
impl<'a> Clone for ExpansionModifier<'a>
Source§fn clone(&self) -> ExpansionModifier<'a>
fn clone(&self) -> ExpansionModifier<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more