pub fn expand(source: &str) -> Result<Vec<String>, ArgumentError> {
    let tilde = expand_tilde(source, || {
        dirs::home_dir().map(|p| p.to_string_lossy().to_string())
    })?;

    let variable = expand_vars(tilde.as_str())?;

    let words = split_words(variable.as_str());

    let filenames = expand_filenames(words);

    let quotes = expand_quotes(filenames)?;

    Ok(quotes)
}
/// Expands a line of input in a similar order to Bash as described in the
/// [Shell Expansions](https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html)
/// section of the documentation:
///
/// > The order of expansions is: brace expansion; tilde expansion, parameter
/// and variable expansion, arithmetic expansion, and command substitution
/// (done in a left-to-right fashion); word splitting; and filename expansion.
/// >
/// > On systems that can support it, there is an additional expansion available:
/// process substitution. This is performed at the same time as tilde,
/// parameter, variable, and arithmetic expansion and command substitution.
/// >
/// > After these expansions are performed, quote characters present in the
/// original word are removed unless they have been quoted themselves (quote
/// removal).
///
/// Since wrash does not support [Brace Expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
/// [Command Substitution](https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html),
/// [Arithmetic Expansion](https://www.gnu.org/software/bash/manual/html_node/Arithmetic-Expansion.html),
/// or [Process Substitution](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html)
/// those steps are ignored.
///
/// todo: validate sequences and escapes before expanding
/// todo: tilde (~) expansion
/// todo: variable / parameter expansion
/// todo: word splitting
/// todo: filename expansion
Expands a line of input in a similar order to Bash as described in the
[Shell Expansions]
section of the documentation.

> The order of expansions is: brace expansion; tilde expansion, parameter
and variable expansion, arithmetic expansion, and command substitution
(done in a left-to-right fashion); word splitting; and filename expansion.
>
> On systems that can support it, there is an additional expansion available:
process substitution. This is performed at the same time as tilde,
parameter, variable, and arithmetic expansion and command substitution.
>
> After these expansions are performed, quote characters present in the
original word are removed unless they have been quoted themselves (quote
removal).

Since wrash does not support [Brace Expansion],
[Command Substitution],
[Arithmetic Expansion],
or [Process Substitution]
those steps are ignored.

validate sequences and escapes before expanding
todo: tilde (~) expansion
todo: variable / parameter expansion
todo: word splitting
todo: filename expansion
Expands a line of input in a similar order to Bash as described in the [ Shell Expansions ] section of the documentation . > The order of expansions is : brace expansion ; tilde expansion parameter and variable expansion arithmetic expansion and command substitution ( done in a left - to - right fashion ) ; word splitting ; and filename expansion . > > On systems that can support it there is an additional expansion available : process substitution . This is performed at the same time as tilde parameter variable and arithmetic expansion and command substitution . > > After these expansions are performed quote characters present in the original word are removed unless they have been quoted themselves ( quote removal ) . Since wrash does not support [ Brace Expansion ] [ Command Substitution ] [ Arithmetic Expansion ] or [ Process Substitution ] those steps are ignored . validate sequences and escapes before expanding todo : tilde ( ~ ) expansion todo : variable / parameter expansion todo : word splitting todo : filename expansion
pub fn expand(source: &str) -> Result<Vec<String>, ArgumentError> {
    let tilde = expand_tilde(source, || {
        dirs::home_dir().map(|p| p.to_string_lossy().to_string())
    })?;
    let variable = expand_vars(tilde.as_str())?;
    let words = split_words(variable.as_str());
    let filenames = expand_filenames(words);
    let quotes = expand_quotes(filenames)?;
    Ok(quotes)
}
pub fn expand ( source : & str ) -> Result < Vec < String > , ArgumentError > { let tilde = expand_tilde ( source , | | { dirs :: home_dir ( ) . map ( | p | p . to_string_lossy ( ) . to_string ( ) ) } ) ? ; let variable = expand_vars ( tilde . as_str ( ) ) ? ; let words = split_words ( variable . as_str ( ) ) ; let filenames = expand_filenames ( words ) ; let quotes = expand_quotes ( filenames ) ? ; Ok ( quotes ) }
Expands a line of input in a similar order to Bash as described in the
[Shell Expansions](https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html)
section of the documentation:
Expands a line of input in a similar order to Bash as described in the [ Shell Expansions ] ( https : // www . gnu . org / software / bash / manual / html_node / Shell - Expansions . html ) section of the documentation :
source
&str