You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for providing sh, I'm a happy user of it in my own little hobby project (gitlint).
I've ran into the following issue.
When trying to pass explicitely empty stdin input like so:
fromshimportcatcat(_in="")
# orcat(_in=None)
Then sh will hang (I suspect it's waiting for input).
I understand you can work around this like so:
fromshimportcatmyvar="..."# result of fancy business logicifmyvarisNoneormyvar=="":
cat()
else:
cat(_in=myvar)
But I'd argue that sh should be able to deal with this natively, since I'd think it's quite common to do some other business logic that results in something passed into sh via _in. That input might be empty.
In addition, if the application that you're calling actually checks whether or not it's receiving data on stdin (e.g. len(stdin.read())==0), then you can't invoke this behavior with sh without using a work-around like so:
since self.stdin = stdin or Queue() will always result in self.stdin=Queue() if stdin is None or an empty string.
However, just adding an extra if statement to deal with this case isn't enough to fix this - and I'm not familiar enough with the sh codebase to know what the best approach to this would be.
Interested to hear your thoughts :-)
The text was updated successfully, but these errors were encountered:
Hi!
Thanks for providing
sh
, I'm a happy user of it in my own little hobby project (gitlint).I've ran into the following issue.
When trying to pass explicitely empty stdin input like so:
Then
sh
will hang (I suspect it's waiting for input).I understand you can work around this like so:
But I'd argue that
sh
should be able to deal with this natively, since I'd think it's quite common to do some other business logic that results in something passed intosh
via_in
. That input might be empty.In addition, if the application that you're calling actually checks whether or not it's receiving data on stdin (e.g.
len(stdin.read())==0
), then you can't invoke this behavior withsh
without using a work-around like so:I've done a little bit of digging on how to solve this in
sh
, and I think the issue starts here:https://github.com/amoffat/sh/blob/master/sh.py#L2023
since
self.stdin = stdin or Queue()
will always result inself.stdin=Queue()
ifstdin
isNone
or an empty string.However, just adding an extra if statement to deal with this case isn't enough to fix this - and I'm not familiar enough with the
sh
codebase to know what the best approach to this would be.Interested to hear your thoughts :-)
The text was updated successfully, but these errors were encountered: