sh icon indicating copy to clipboard operation
sh copied to clipboard

_tee supports only one of stderr or stdout

Open graingert opened this issue 10 years ago • 2 comments

Ideally I'd like

  • sh.command(_err=callback, _out=callback, _tee=True) to buffer both stderr and stdout
  • sh.command(_err=callback, _out=callback, _tee=1) to buffer both stderr and stdout
  • sh.command(_err=callback, _out=callback, _tee=('err', 'out')) to buffer both stderr and stdout
  • sh.command(_err=callback, _out=callback, _tee=('err',)) to buffer stderr
  • sh.command(_err=callback, _out=callback, _tee=('out',)) to buffer stdout

Of course this would make this an API breaking change 2.0.0?

graingert avatar Jan 06 '15 13:01 graingert

I agree, I feel this is what you would intuitively expect given the inputs.

MichaelAquilina avatar Jan 06 '15 13:01 MichaelAquilina

You can get both to work using:

class ErrOutStr(str):
    '''A str that is in ('err',) and ('out',)'''

    def __eq__(self, other):
        return other in ('err', 'out')


_err_out_str = ErrOutStr()

def do_something_with_sh(...):
    sh.command(_err=callback, _out=callback, _tee=_err_out_str)

graingert avatar Jan 06 '15 14:01 graingert

Support for both "err" and "out" in _tee is live in 2.0.0. It only took *checks date* 8 years 🤣 😭 ⏳

amoffat avatar Feb 09 '23 20:02 amoffat