docs: def line2argv(line):
      r"""Parse the given line into an argument vector.
  
          "line" is the line of input to parse.
  
      This may get niggly when dealing with quoting and escaping. The
      current state of this parsing may not be completely thorough/correct
      in this respect.
  
      >>> from cmdln import line2argv
      >>> line2argv("foo")
      ['foo']
      >>> line2argv("foo bar")
      ['foo', 'bar']
      >>> line2argv("foo bar ")
      ['foo', 'bar']
      >>> line2argv(" foo bar")
      ['foo', 'bar']
  
      Quote handling:
  
      >>> line2argv("'foo bar'")
      ['foo bar']
      >>> line2argv('"foo bar"')
      ['foo bar']
      >>> line2argv(r'"foo\"bar"')
      ['foo"bar']
      >>> line2argv("'foo bar' spam")
      ['foo bar', 'spam']
      >>> line2argv("'foo 'bar spam")
      ['foo bar', 'spam']
  
      >>> line2argv('some\tsimple\ttests')
      ['some', 'simple', 'tests']
      >>> line2argv('a "more complex" test')
      ['a', 'more complex', 'test']
      >>> line2argv('a more="complex test of " quotes')
      ['a', 'more=complex test of ', 'quotes']
      >>> line2argv('a more" complex test of " quotes')
      ['a', 'more complex test of ', 'quotes']
      >>> line2argv('an "embedded \\"quote\\""')
      ['an', 'embedded "quote"']
  
      # Komodo bug 48027
      >>> line2argv('foo bar C:\\')
      ['foo', 'bar', 'C:\\']
  
      # Komodo change 127581
      >>> line2argv(r'"\test\slash" "foo bar" "foo\"bar"')
      ['\\test\\slash', 'foo bar', 'foo"bar']
  
      # Komodo change 127629
      >>> if sys.platform == "win32":
      ...     line2argv(r'\foo\bar') == ['\\foo\\bar']
      ...     line2argv(r'\\foo\\bar') == ['\\\\foo\\\\bar']
      ...     line2argv('"foo') == ['foo']
      ... else:
      ...     line2argv(r'\foo\bar') == ['foobar']
      ...     line2argv(r'\\foo\\bar') == ['\\foo\\bar']
      ...     try:
      ...         line2argv('"foo')
      ...     except ValueError as ex:
      ...         "not terminated" in str(ex)
      True
      True
      True
      """
      line = line.strip()
      argv = []
      state = "default"
      arg = None  # the current argument being parsed
      i = -1
      WHITESPACE = '\t\n\x0b\x0c\r '  # don't use string.whitespace (bug 81316)
      while 1:
          i += 1
          if i >= len(line): break
          ch = line[i]
  
          if ch == "\\" and i + 1 < len(line):
              # escaped char always added to arg, regardless of state
              if arg is None: arg = ""
              if (sys.platform == "win32" or
                      state in ("double-quoted", "single-quoted")
                  ) and line[i + 1] not in tuple('"\''):
                  arg += ch
              i += 1
              arg += line[i]
              continue
  
          if state == "single-quoted":
              if ch == "'":
                  state = "default"
              else:
                  arg += ch
          elif state == "double-quoted":
              if ch == '"':
                  state = "default"
              else:
                  arg += ch
          elif state == "default":
              if ch == '"':
                  if arg is None: arg = ""
                  state = "double-quoted"
              elif ch == "'":
                  if arg is None: arg = ""
                  state = "single-quoted"
              elif ch in WHITESPACE:
                  if arg is not None:
                      argv.append(arg)
                  arg = None
              else:
                  if arg is None: arg = ""
                  arg += ch
      if arg is not None:
          argv.append(arg)
      if not sys.platform == "win32" and state != "default":
          raise ValueError("command line is not terminated: unfinished %s "
                           "segment" % state)
      return argv