amoffat / sh

Python process launching

Home Page:https://sh.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Piping fails on `sh` 2.0.x

anatoly-scherbakov opened this issue · comments

Testing the following example from the documentation:

wc(ls("/etc", "-1"), "-l")

gives a crash on every version ⩾ 2.0.0:

(jeeves-shell) anatoly@anatoly-laptop:~/research/jeeves-shell$ pip freeze | grep 'sh='
sh==2.0.4
(jeeves-shell) anatoly@anatoly-laptop:~/research/jeeves-shell$ python
Python 3.10.8 (main, Nov 27 2022, 11:45:09) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sh import wc, ls
>>> wc(ls("/etc", "-1"), "-l")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/anatoly/.pyenv/versions/jeeves-shell/lib/python3.10/site-packages/sh.py", line 1524, in __call__
    rc = self.__class__.RunningCommandCls(cmd, call_args, stdin, stdout, stderr)
  File "/home/anatoly/.pyenv/versions/jeeves-shell/lib/python3.10/site-packages/sh.py", line 750, in __init__
    self.wait()
  File "/home/anatoly/.pyenv/versions/jeeves-shell/lib/python3.10/site-packages/sh.py", line 812, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/anatoly/.pyenv/versions/jeeves-shell/lib/python3.10/site-packages/sh.py", line 839, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /usr/bin/wc 'acpi
adduser.conf
…
xml
zsh_command_not_found
' -l

  STDOUT:


  STDERR:
/usr/bin/wc: 'acpi'$'\n''ad… (3081 more, please see e.stderr)

It works as intended on 1.14.3.

commented

Closing as duplicate of #656