{"id":17219454,"url":"https://github.com/colin-pm/grash","last_synced_at":"2026-04-28T20:35:33.428Z","repository":{"id":54117601,"uuid":"335322115","full_name":"colin-pm/grash","owner":"colin-pm","description":"Bash dependency analyzer","archived":false,"fork":false,"pushed_at":"2021-03-09T04:37:42.000Z","size":78,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T14:45:05.644Z","etag":null,"topics":["bash","dependency-parser","python3"],"latest_commit_sha":null,"homepage":"","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/colin-pm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-02T14:47:44.000Z","updated_at":"2021-03-09T04:37:44.000Z","dependencies_parsed_at":"2022-08-13T07:00:31.628Z","dependency_job_id":null,"html_url":"https://github.com/colin-pm/grash","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/colin-pm/grash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-pm%2Fgrash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-pm%2Fgrash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-pm%2Fgrash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-pm%2Fgrash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colin-pm","download_url":"https://codeload.github.com/colin-pm/grash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-pm%2Fgrash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32398966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bash","dependency-parser","python3"],"created_at":"2024-10-15T03:49:52.996Z","updated_at":"2026-04-28T20:35:33.397Z","avatar_url":"https://github.com/colin-pm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grash\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/colin-pm/grash/Python%20package)\n[![codecov](https://codecov.io/gh/colin-pm/grash/branch/master/graph/badge.svg?token=VKKFM22615)](https://codecov.io/gh/colin-pm/grash)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/grash)\n\nA dependency analysis tool for bash scripts.\n\n## Purpose\n\nThis tool was created as a way to quickly evaluate the executables a bash script depends on.  It works by parsing one or more scripts and finding the names of everything that is executed.  It then compares that list against the files in the environment's path and returns the common set.\n\n## Installation\n\n### From PyPi\n\n```shell\npip install grash\ngrash -h\n```\n\n### From source\n\nClone down the project and install with Poetry.\n\n```shell\ngit clone git@github.com:colin-pm/grash.git\ncd grash\npoetry install\npoetry shell\ngrash -h\n```\n\n## Usage\n\nCurrently, Grash only supports printing out the dependencies for the selected script.  Future functionality is intended to be implemented to generate a visual network graph of dependencies.\n\nTo evaluate the dependencies in a script, execute a command like the one below.\n\nWith foo.sh...\n```shell\n#!/usr/bin/env bash\nfor FILE in $(ls $1); do\n  if [ ${FILE: -4} == .txt ]; then\n    rm $FILE\n  fi\ndone\necho \"Cleared out all .txt files\"\n```\n\nRun...\n```shell\n$ grash inspect foo.sh\nScript: foo.sh\nhas dependencies...\necho\nls\nrm\n```\n\nSeveral scripts can be evaluated at the same time.\n\n```shell\n$ echo '#!/usr/bin/env bash' \u003e bar.sh\n$ echo 'echo \"This is a test\"' \u003e\u003e bar.sh\n$ grash inspect foo.sh bar.sh\nScript: foo.sh\nhas dependencies...\necho\nls\nmkdir\nrm\n\nScript: bar.sh\nhas dependencies...\necho\n```\n\nIf you want to use a PATH other than the PATH provided by the system.  The ```-p``` flag can be used to specify an exclusive PATH for grash to use.\n\nThe ```-p``` flag is intended for evaluating scripts that may be used on a separate root filesystem, like the target root filesystem within Buildroot.\n\n```shell\n$ grash inspect -p \"~/.local/bin:/usr/sbin\" foo.sh\nScript: foo.sh\nhas dependencies...\nmy-script.sh\n```\n\n## Variable expansion\n\nGrash will recognize evaluation of variables. For example, Grash will recognize ```my_script``` and ```bar``` as dependencies in the example below.\n```shell\nCOMMAND='my_script foo | bar'\neval $COMMAND\n```\n\nNested variables are also supported. For example, both ```my_script``` and ```bar``` are recognized as dependencies by Grash in the example below.\n```shell\nCOMMAND_ONE='bar'\nCOMMAND_TWO=\"my_script foo | ${COMMAND_ONE}\"\neval $COMMAND_TWO\n```\n\n## Caveats\n\n## Calling other scripts\n\nScripts called with source will be recognized as a dependency, but evaluating contents from another file will not be recognized as a dependency\n\n```eval $(cat foo.sh)``` will not recognize foo.sh as a dependency. However, ```source foo.sh``` will recognize foo.sh as a dependency.\n\n## Case statements\n\nCase statements are not supported by bashlex, the parser used by Grash.  Grash's preprocessor will remove the case-specific lines from the script.  However, since control flow is not needed for parsing dependencies, the code for each case is left.  If you use case statments in your script, ensure the case syntax is on separate lines like the example below.\n\n```shell\ncase \"$1\" in\n        start)\n            start\n            ;;\n         \n        stop)\n            stop\n            ;;\n         \n        status)\n            status anacron\n            ;;\n        restart)\n            stop\n            start\n            ;;\n        condrestart)\n            if test \"x`pidof anacron`\" != x; then\n                stop\n                start\n            fi\n            ;;\n         \n        *)\n            echo $\"Usage: $0 {start|stop|restart|condrestart|status}\"\n            exit 1\nesac\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolin-pm%2Fgrash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolin-pm%2Fgrash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolin-pm%2Fgrash/lists"}