{"id":13501841,"url":"https://github.com/timofurrer/shellfuncs","last_synced_at":"2025-08-21T05:31:47.530Z","repository":{"id":57466718,"uuid":"74891443","full_name":"timofurrer/shellfuncs","owner":"timofurrer","description":"Python API to execute shell functions as they would be Python functions","archived":true,"fork":false,"pushed_at":"2023-05-27T06:49:21.000Z","size":34,"stargazers_count":101,"open_issues_count":1,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-04T15:36:55.904Z","etag":null,"topics":["api","bash","environment","execute","function","import","interface","shell","source","subprocess"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timofurrer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-11-27T14:06:50.000Z","updated_at":"2025-03-07T19:20:25.000Z","dependencies_parsed_at":"2024-01-23T00:16:34.034Z","dependency_job_id":"a7a5b999-fe6e-4e75-b7f2-383e213b0e44","html_url":"https://github.com/timofurrer/shellfuncs","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"522f62d5716e441f343b29cf7a04b70c6fc44f6e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/timofurrer/shellfuncs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timofurrer%2Fshellfuncs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timofurrer%2Fshellfuncs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timofurrer%2Fshellfuncs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timofurrer%2Fshellfuncs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timofurrer","download_url":"https://codeload.github.com/timofurrer/shellfuncs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timofurrer%2Fshellfuncs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271430739,"owners_count":24758362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bash","environment","execute","function","import","interface","shell","source","subprocess"],"created_at":"2024-07-31T22:01:52.840Z","updated_at":"2025-08-21T05:31:47.236Z","avatar_url":"https://github.com/timofurrer.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# shellfuncs\n\n[![Build Status](https://travis-ci.com/timofurrer/shellfuncs.svg?token=qRcMyciKYsuEPapoF8ny\u0026branch=master)](https://travis-ci.com/timofurrer/shellfuncs)\n[![PyPI package version](https://badge.fury.io/py/shellfuncs.svg)](https://badge.fury.io/py/shellfuncs)\n[![PyPI python versions](https://img.shields.io/pypi/pyversions/shellfuncs.svg)](https://pypi.python.org/pypi/shellfuncs)\n\nPython API to execute functions written in shell script.\n\nLet's assume you have a shell script *counters.sh* like this:\n\n```bash\ncount_python_imports() {\n    find -name '*.py' | xargs grep -e '^import os$' -e '^import sys$' -e '^import re$' | cut -d: -f2 | sort | uniq -c\n}\n```\n\nAnd you want to execute the `count_python_imports` function within Python. Instead of using cumbersome *subprocess* wouldn't it be awesome to do something like this:\n\n```python\nimport shellfuncs\n\nfrom counters import count_python_imports\n\nreturncode, stdout, stderr = count_python_imports()\n```\n\n*Yeah, yeah, I know about easier ways of achieving the above, too. Thanks.*\n\n## Why should I use that?\n\n* use existing shell scripts in a pythonic way\n* complex piping stuff might be easier to implement in shell script\n* testing shell scripts is a pain in the a\\*\\* - with Python it'll be easier\n\n## Installation\n\nThe recommended way to install **shellfuncs** is to use `pip`:\n\n```shell\npip install shellfuncs\n```\n\n## Usage\n\n**shellfuncs** can be configured on different levels.\n\nThe following configuration variables are available:\n\n* shell (defaults to `/bin/sh`)\n* env (defaults to `os.environ`)\n\n### Configuration via environment variables\n\nSet the default shell via `SHELLFUNCS_DEFAULT_SHELL` environment variable:\n\n```bash\nexport SHELLFUNCS_DEFAULT_SHELL=/bin/bash\n```\n\n### Configuration via context manager\n\nSet the configuration block-wise with a context manager:\n\n```python\nimport shellfuncs\n\nwith shellfuncs.config(shell='/bin/bash'):\n    from counters import count_python_imports\n\ncount_python_imports()  # the shell used will be /bin/bash\n```\n\n### Configuration for specific function call\n\nSet the configuration when function is executed:\n\n```python\nimport shellfuncs\n\nfrom counters import count_python_imports\n\ncount_python_imports(shell='/bin/bash')\n```\n\n***\n\n*\u003cp align=\"center\"\u003eThis project is published under [MIT](LICENSE).\u003cbr\u003eA [Timo Furrer](https://tuxtimo.me) project.\u003cbr\u003e- :tada: -\u003c/p\u003e*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimofurrer%2Fshellfuncs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimofurrer%2Fshellfuncs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimofurrer%2Fshellfuncs/lists"}