Skip to main content

expand_dollar_variables

Function expand_dollar_variables 

Source
pub fn expand_dollar_variables(
    input: &str,
    reject_undefined: bool,
) -> Result<String, PathError>
Expand description

Expand $VAR and ${VAR} style environment variables.

Rules:

  • ${VAR} requires a closing }
  • $VAR matches [A-Za-z_][A-Za-z0-9_]*
  • $123 is not a variable (digit-leading names are not expanded)
  • $( is never expanded (command substitution is unsupported)
  • Backticks are never expanded

Undefined variables: error when reject_undefined is true; otherwise leave the token.