code: def line_to_args(self, line):
          
          # Note: using shlex.split causes quoted substrings to stay together.
          args = shlex.split(line)
          self.redirect_filename = ''
          self.redirect_dev = None
          redirect_index = -1
          if '>' in args:
              redirect_index = args.index('>')
          elif '>>' in args:
              redirect_index = args.index('>>')
          if redirect_index >= 0:
              if redirect_index + 1 >= len(args):
                  raise ShellError("> requires a filename")
              self.redirect_filename = resolve_path(args[redirect_index + 1])
              rmode = auto(get_mode, os.path.dirname(self.redirect_filename))
              if not mode_isdir(rmode):
                  raise ShellError("Unable to redirect to '%s', directory doesn't exist" %
                                   self.redirect_filename)
              if args[redirect_index] == '>':
                  self.redirect_mode = 'w'
                  if DEBUG:
                      print('Redirecting (write) to', self.redirect_filename)
              else:
                  self.redirect_mode = 'a'
                  if DEBUG:
                      print('Redirecting (append) to', self.redirect_filename)
              self.redirect_dev, self.redirect_filename = get_dev_and_path(self.redirect_filename)
              try:
                  if self.redirect_dev is None:
                      self.stdout = SmartFile(open(self.redirect_filename, self.redirect_mode))
                  else:
                      # Redirecting to a remote device. We collect the results locally
                      # and copy them to the remote device at the end of the command.
                      self.stdout = SmartFile(tempfile.TemporaryFile(mode='w+'))
              except OSError as err:
                  raise ShellError(err)
  
              del args[redirect_index + 1]
              del args[redirect_index]
          curr_cmd, _, _ = self.parseline(self.lastcmd)
          parser = self.create_argparser(curr_cmd)
          if parser:
              args = parser.parse_args(args)
          return args
docs: This will convert the line passed into the do_xxx functions into
          an array of arguments and handle the Output Redirection Operator.