Expand description
Word expansion.
The word expansion involves many kinds of operations described below.
The expand_word_multiple function performs all of them and produces
any number of fields depending on the expanded word. The expand_word_attr
and expand_word functions omit some of them to ensure that the result is
a single field. Other functions in this module are provided for convenience
in specific situations.
§Initial expansion
The initial expansion is the first step of the word
expansion that evaluates a Word to a Phrase. It is
performed by recursively calling Expand implementors’ methods. Notable
(sub)expansions that may occur in the initial expansion include the tilde
expansion, parameter expansion, command substitution, and arithmetic
expansion.
A successful initial expansion of a word usually results in a single-field
phrase. Still, it may yield any number of fields if the word contains a
parameter expansion of $@ or $*.
§Multi-field expansion
The multi-field expansion is a group of operation steps performed after the initial expansion to render final multi-field results.
§Brace expansion
The brace expansion produces copies of a field containing a pair of braces. (TODO: This feature is not yet implemented.)
§Field splitting
The field splitting divides a field into smaller parts delimited by
a character contained in $IFS. Consequently, this operation removes empty
fields from the results of the previous steps.
§Pathname expansion
The pathname expansion performs pattern matching on the name of existing files to produce pathnames. This operation is also known as “globbing.”
§Quote removal and attribute stripping
The quote removal drops characters quoting other
characters, and the attribute stripping converts
AttrFields into bare Fields. In expand_word_multiple, the quote
removal is performed between the field splitting and pathname expansion, and
the attribute stripping is part of the pathname expansion. In
expand_word, they are carried out as the last step of the whole
expansion.
Re-exports§
pub use yash_env::semantics::Field;pub use yash_env::semantics::expansion::attr;pub use yash_env::semantics::expansion::attr_strip;pub use yash_env::semantics::expansion::quote_removal;pub use yash_env::semantics::expansion::split;
Modules§
- glob
- Pathname expansion
- initial
- Initial expansion
- phrase
- Array of fields as an intermediate expansion result
Structs§
- Assign
Read Only Error - Error returned on assigning to a read-only variable
- Error
- Explanation of an expansion failure.
Enums§
- Error
Cause - Types of errors that may occur in the word expansion.
Functions§
- expand_
text - Expands a text to a string.
- expand_
value - Expands an assignment value.
- expand_
word - Expands a word to a field.
- expand_
word_ attr - Expands a word to an attributed field.
- expand_
word_ multiple - Expands a word to fields.
- expand_
word_ with_ mode - Expands a word to fields.
- expand_
words - Expands words to fields.
Type Aliases§
- Result
- Result of word expansion.