parameters: (path)
return_statement: return path
docstring: Expand shell variables of form $var and ${var}.  Unknown variables
      are left unchanged.
docstring_summary: Expand shell variables of form $var and ${var}.  Unknown variables
      are left unchanged.
docstring_tokens: Expand shell variables of form $var and $ { var } . Unknown variables are left unchanged .
function: def expandvars(path):
      """Expand shell variables of form $var and ${var}.  Unknown variables
      are left unchanged."""
      global _varprog
      if '$' not in path:
          return path
      if not _varprog:
          import re
          _varprog = re.compile(r'\$(\w+|\{[^}]*\})')
      i = 0
      while True:
          m = _varprog.search(path, i)
          if not m:
              break
          i, j = m.span(0)
          name = m.group(1)
          if name.startswith('{') and name.endswith('}'):
              name = name[1:-1]
          if name in os.environ:
              tail = path[j:]
              path = path[:i] + os.environ[name]
              i = len(path)
              path += tail
          else:
              i = j
      return path
function_tokens: def expandvars ( path ) : global _varprog if '$' not in path : return path if not _varprog : import re _varprog = re . compile ( r'\$(\w+|\{[^}]*\})' ) i = 0 while True : m = _varprog . search ( path , i ) if not m : break i , j = m . span ( 0 ) name = m . group ( 1 ) if name . startswith ( '{' ) and name . endswith ( '}' ) : name = name [ 1 : - 1 ] if name in os . environ : tail = path [ j : ] path = path [ : i ] + os . environ [ name ] i = len ( path ) path += tail else : i = j return path