Skip to main content

interpolate_env

Function interpolate_env 

Source
pub fn interpolate_env(input: &str) -> String
Expand description

Replaces ${VAR} and ${VAR:-default} patterns with environment variable values.

Semantics:

  • ${VAR} — substituted with the variable’s value, or the empty string if unset.
  • ${VAR:-default} — substituted with the variable’s value, or default if unset.

Variable names must match [A-Za-z_][A-Za-z0-9_]*; text that does not match the pattern is left untouched. There is no escape syntax for a literal ${...}.