docs: def pipe_commands_to_file(cmds, path, extra_env=None, show_stderr=False):
      """
      Executes the list of commands piping each one into the next and writing
      stdout of the last process into a file at the given path.
      """
      env = extend_env(extra_env) if extra_env else None
      env_str = (get_env_str(extra_env) + ' ') if extra_env else ''
      cmd_strs = [env_str + ' '.join(cmd) for cmd in cmds]
  
      logger.info('Saving output of `{0}`'.format(' | '.join(cmd_strs)))
  
      with open('/dev/null', 'w') as NULL:
          # Start processes
          processes = []
          for cmd_str, cmd in zip(cmd_strs, cmds):
              p_stdin = processes[-1][1].stdout if processes else None
              p_stderr = None if show_stderr else NULL
  
              p = Popen(cmd, env=env, stdout=PIPE, stdin=p_stdin, stderr=p_stderr)
              processes.append((cmd_str, p))
  
          p_last = processes[-1][1]
  
          with open(path, 'wb') as f:
              shutil.copyfileobj(p_last.stdout, f)
  
              # Close processes
              error = False
              for cmd_str, p in processes:
                  p.stdout.close()
                  if p.wait() != 0:
                      error = True
              if error:
                  raise CalledProcessError(cmd=cmd_str, returncode=p.returncode)