If you are migrating from 1.* to 2.*, please see MIGRATION.md
sh is a full-fledged subprocess replacement for Python 3.8 - 3.11, and PyPy that allows you to call any program as if it were a function:
from sh import ifconfig
print(ifconfig("eth0"))
sh is not a collection of system commands implemented in Python.
sh relies on various Unix system calls and only works on Unix-like operating systems - Linux, macOS, BSDs etc. Specifically, Windows is not supported.
$> pip install sh
Tests are run in a docker container against all supported Python versions. To run, make the following target:
$> make testTo run a single test:
$> make test='FunctionalTests.test_background' test_oneFirst run all of the tests:
$> SH_TESTS_RUNNING=1 coverage run --source=sh -m pytestThis will aggregate a
.coverage
. You may then visualize the report with:$> coverage reportOr generate visual html files with:
$> coverage htmlWhich will create
./htmlcov/index.html
that you may open in a web browser.