diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8778236..5bed69cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,22 +14,22 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache pip directory with: path: ~/.cache/pip key: ${{ runner.os }}-pip-3.9 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache poetry deps with: path: .venv key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.9 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -60,15 +60,15 @@ jobs: lang: [C, en_US.UTF-8] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache pip directory with: path: ~/.cache/pip key: ${{ runner.os }}-pip-3.9 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache poetry deps env: cache-name: poetry-deps @@ -77,7 +77,7 @@ jobs: key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -92,13 +92,13 @@ jobs: - name: Run tests run: | - SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run -a -m pytest + SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run --data-file=coverage.data -a -m pytest - name: Store coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage.${{ matrix.use-select }}.${{ matrix.lang }}.${{ matrix.python-version }} - path: .coverage + path: coverage.data report: name: Report Coverage @@ -106,10 +106,10 @@ jobs: runs-on: ubuntu-latest steps: # required because coveralls complains if we're not in a git dir - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -118,13 +118,13 @@ jobs: pip install coverage coveralls - name: Download coverage artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: coverage-artifacts - name: Combine coverage run: | - find coverage-artifacts -name .coverage | xargs coverage combine -a + find coverage-artifacts -name coverage.data | xargs coverage combine -a - name: Report coverage env: @@ -143,7 +143,7 @@ jobs: id-token: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Get current version id: get_version @@ -155,7 +155,7 @@ jobs: git push -f origin "${{steps.get_version.outputs.version}}" - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 diff --git a/docs/source/sections/contrib.rst b/docs/source/sections/contrib.rst index c18877ee..dd189437 100644 --- a/docs/source/sections/contrib.rst +++ b/docs/source/sections/contrib.rst @@ -130,6 +130,32 @@ this. The currently written character. + +.. _contrib_bash: + +Bash +--- + +Often users may find themselves having to run bash commands directly, whether due +to commands having special characters (e.g. dash, or dot) or other reasons. +This can lead into recurrently having to bake the ``bash`` command to call it directly. To +account for this, the contrib version provides a ``bash`` command baked in: + +.. py:function:: bash(*args, **kwargs) + + Call bash with the prefix of "bash -c [...]". + +.. code-block:: python + + from sh.contrib import bash + + # Calling commands directly + bash.ls() # equivallent to "bash -c ls" + + # Or adding the full commands + bash("command-with-dashes args") + + Extending ========= diff --git a/sh.py b/sh.py index 556df8ff..4a83a3ac 100644 --- a/sh.py +++ b/sh.py @@ -3471,6 +3471,12 @@ def git(orig): # pragma: no cover return cmd +@contrib("bash") +def bash(orig): + cmd = orig.bake("-c") + return cmd + + @contrib("sudo") def sudo(orig): # pragma: no cover """a nicer version of sudo that uses getpass to ask for a password, or