Skip to main content

Module interp

Module interp 

Source
Expand description

Compose-style variable interpolation.

Supported: $VAR, ${VAR}, ${VAR:-default} (unset or empty), ${VAR-default} (unset only), ${VAR:?message} / ${VAR?message} (error), ${VAR:+alt} / ${VAR+alt}, and $$ for a literal $. Defaults may themselves contain interpolations. An unset variable with no default is an error, not an empty string: an empty bind path or label is worse than a failed parse.

Interpolation runs on string scalars (and mapping keys) of the parsed YAML tree, never on the raw text, so a value cannot inject YAML structure.

Functionsยง

interpolate
Interpolate s using lookup for variable values.
interpolate_yaml
Interpolate every string scalar and mapping key in a YAML tree, in place.
parse_env_file
Parse a dotenv-style file: KEY=VALUE lines, # comments, optional export , optional single or double quotes around the value. No expansion.
references
The variables s refers to, in order of appearance (with repeats), the ones inside a default or alternate included: what interpolate may look up. Malformed references are skipped (interpolating reports them).