parameters: (str)
return_statement: return str
docstring: Takes a string containing variable references in the form ${FOO}, $(FOO),
    or $FOO, and returns a string with all variable references in the form ${FOO}.
docstring_summary: Takes a string containing variable references in the form ${FOO}, $(FOO),
    or $FOO, and returns a string with all variable references in the form ${FOO}.
docstring_tokens: Takes a string containing variable references in the form $ { FOO } $ ( FOO ) or $FOO and returns a string with all variable references in the form $ { FOO } .
function: def _NormalizeEnvVarReferences(str):
    """Takes a string containing variable references in the form ${FOO}, $(FOO),
    or $FOO, and returns a string with all variable references in the form ${FOO}.
    """
    # $FOO -> ${FOO}
    str = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'${\1}', str)
  
    # $(FOO) -> ${FOO}
    matches = re.findall(r'(\$\(([a-zA-Z0-9\-_]+)\))', str)
    for match in matches:
      to_replace, variable = match
      assert '$(' not in match, '$($(FOO)) variables not supported: ' + match
      str = str.replace(to_replace, '${' + variable + '}')
  
    return str
function_tokens: def _NormalizeEnvVarReferences ( str ) : # $FOO -> ${FOO} str = re . sub ( r'\$([a-zA-Z_][a-zA-Z0-9_]*)' , r'${\1}' , str ) # $(FOO) -> ${FOO} matches = re . findall ( r'(\$\(([a-zA-Z0-9\-_]+)\))' , str ) for match in matches : to_replace , variable = match assert '$(' not in match , '$($(FOO)) variables not supported: ' + match str = str . replace ( to_replace , '${' + variable + '}' ) return str