code: def expandvars(path):
      """Expand shell variables of form $var and ${var}.  Unknown variables
      are left unchanged."""
      path = os.fspath(path)
      global _varprog, _varprogb
      if isinstance(path, bytes):
          if b"$" not in path:
              return path
          if not _varprogb:
              import re
  
              _varprogb = re.compile(rb"\$(\w+|\{[^}]*\})", re.ASCII)
          search = _varprogb.search
          start = b"{"
          end = b"}"
          environ = getattr(os, "environb", None)
      else:
          if "$" not in path:
              return path
          if not _varprog:
              import re
  
              _varprog = re.compile(r"\$(\w+|\{[^}]*\})", re.ASCII)
          search = _varprog.search
          start = "{"
          end = "}"
          environ = os.environ
      i = 0
      while True:
          m = search(path, i)
          if not m:
              break
          i, j = m.span(0)
          name = m.group(1)
          if name.startswith(start) and name.endswith(end):
              name = name[1:-1]
          try:
              if environ is None:
                  value = os.fsencode(os.environ[os.fsdecode(name)])
              else:
                  value = environ[name]
          except KeyError:
              i = j
          else:
              tail = path[j:]
              path = path[:i] + value
              i = len(path)
              path += tail
      return path
  
imports: import os
  import sys
  import stat
  import genericpath
  from genericpath import *
label_desc: Use image node_id 14 for calling a global function with example usage: expandvars(path) and returns: path, path, path