Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_tee has no effect when passing a pipe as _out / _err #384

Closed
fletom opened this issue May 12, 2017 · 2 comments
Closed

_tee has no effect when passing a pipe as _out / _err #384

fletom opened this issue May 12, 2017 · 2 comments
Labels

Comments

@fletom
Copy link

fletom commented May 12, 2017

sh version: 1.12.13

In [13]: sh.curl('-I', 'example.com').stdout
Out[13]: b'HTTP/1.1 200 OK\r\nContent-Encoding: gzip\r\nAccept-Ranges: bytes\r\nCache-Control: max-age=604800\r\nContent-Type: text/html\r\nDate: Fri, 12 May 2017 04:09:21 GMT\r\nEtag: "359670651+gzip"\r\nExpires: Fri, 19 May 2017 04:09:21 GMT\r\nLast-Modified: Fri, 09 Aug 2013 23:54:35 GMT\r\nServer: ECS (ewr/15BD)\r\nX-Cache: HIT\r\nContent-Length: 606\r\n\r\n'

In [14]: sh.curl('-I', 'example.com', _out = sys.stdout, _tee = True).stdout
HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Fri, 12 May 2017 04:09:48 GMT
Etag: "359670651+gzip"
Expires: Fri, 19 May 2017 04:09:48 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (ewr/15BD)
X-Cache: HIT
Content-Length: 606

Out[14]: b''

the same behaviour occurs with _tee = 'out' too

@amoffat
Copy link
Owner

amoffat commented May 12, 2017

This seems to only not be working with when a pipe or tty is passed to _out/_err, probably due to the fact that if that is the case, we os.dup2 the pipe/tty's file descriptor into the processes's stdout/stderr. Meaning there is no way for us to intercept the data flowing from the process into the output handler, since it's connected directly. This seems like a bug. Thanks for reporting

@amoffat amoffat added the bug label May 12, 2017
@fletom fletom changed the title _tee seems to have no effect _tee has no effect when passing a pipe as _out / _err May 12, 2017
@amoffat
Copy link
Owner

amoffat commented Jun 7, 2017

Fixed on master, version 1.12.14

@amoffat amoffat closed this as completed Jun 7, 2017
0-wiz-0 added a commit to NetBSD/pkgsrc-wip that referenced this issue Jun 19, 2017
*   bugfix for poor sleep performance [#378](amoffat/sh#378)
*   allow passing raw integer file descriptors for `_out` and `_err` handlers
*   bugfix for when `_tee` and `_out` are used, and the `_out` is a tty or pipe [#384](amoffat/sh#384)
*   bugfix where python 3.3+ detected different arg counts for bound method output callbacks [#380](amoffat/sh#380)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants