code: def connect(*cmds, **kwargs):
      
      stdin = kwargs.get("stdin")
      env = kwargs.get("env", os.environ)
      timeout = kwargs.get("timeout")
      end = len(cmds) - 1
  
      @contextmanager
      def inner(idx, inp):
          with stream(cmds[idx], stdin=inp, env=env, timeout=timeout) as s:
              if idx == end:
                  yield s
              else:
                  with inner(idx + 1, s) as c:
                      yield c
  
      with inner(0, stdin) as s:
          yield s
docs: Connects multiple command streams together and yields the final stream.
  
      Args:
          cmds (list): list of commands to pipe together. Each command will be an
              input to ``stream``.
          stdin (file like object): stream to use as the first command's
              standard input.
          env (dict): The environment in which to execute the commands. PATH
              should be defined.
          timeout (int): Amount of time in seconds to give the pipeline to complete.
              The ``timeout`` utility must be installed to use this feature.
  
      Yields:
          The output stream for the final command in the pipeline. It should
          typically be wrapped in a ``reader``.