def HasVarOpen(segment):
  """Returns True if segment contains a Make variable opening."""
  for open_delim, close_delim in [('$(', ')'), ('${', '}')]:
    open_pos = segment.rfind(open_delim)
    close_pos = segment.rfind(close_delim)
    if open_pos != -1 and (close_pos == -1 or close_pos < open_pos):
      return True
  return False