interpolate method

String interpolate(
  1. String val,
  2. Map<String, String?> env
)

Substitutes $bash_vars in val with values from env.

Implementation

String interpolate(String val, Map<String, String?> env) =>
    val.replaceAllMapped(_bashVar, (m) {
      if ((m.group(1) ?? "") == "\\") {
        return m.input.substring(m.start, m.end);
      } else {
        var k = m.group(3)!;
        if (!_has(env, k)) return '';
        return env[k]!;
      }
    });