code: def split_line(self, line):
          
          remainder = []
          while True:
              try:
                  args = shlex.split(line)
              except ValueError:
                  remainder.append(line[-1])
                  line = line[:-1]
              else:
                  if remainder:
                      args.append(''.join(reversed(remainder)))
                  return args
docs: Try to do pure shlex.split unless it can't parse the line. In that
          case we trim the input line until shlex can split the args and tack the
          unparsable portion on as the last argument.