docs: def _read_until(infile=sys.stdin, maxchars=20, end=RS):
      ''' Read a terminal response of up to a few characters from stdin.  '''
      chars = []
      read = infile.read
      if not isinstance(end, tuple):
          end = (end,)
  
      # count down, stopping at 0
      while maxchars:
          char = read(1)
          if char in end:
              break
          chars.append(char)
          maxchars -= 1
  
      return ''.join(chars)