{"id":19151544,"url":"https://github.com/johnstarich/bashtion","last_synced_at":"2026-05-16T09:32:45.337Z","repository":{"id":145654098,"uuid":"132560111","full_name":"JohnStarich/bashtion","owner":"JohnStarich","description":"A stronghold for using Bash in production","archived":false,"fork":false,"pushed_at":"2019-06-12T01:30:41.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T20:48:20.480Z","etag":null,"topics":["bash","bashtion","production","shell"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnStarich.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T05:48:29.000Z","updated_at":"2019-06-12T01:29:40.000Z","dependencies_parsed_at":"2023-04-06T09:00:42.482Z","dependency_job_id":null,"html_url":"https://github.com/JohnStarich/bashtion","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/JohnStarich/bashtion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnStarich%2Fbashtion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnStarich%2Fbashtion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnStarich%2Fbashtion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnStarich%2Fbashtion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnStarich","download_url":"https://codeload.github.com/JohnStarich/bashtion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnStarich%2Fbashtion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33096873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","bashtion","production","shell"],"created_at":"2024-11-09T08:14:57.285Z","updated_at":"2026-05-16T09:32:45.316Z","avatar_url":"https://github.com/JohnStarich.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bashtion\n\nA stronghold for using Bash in production\n\nBuild reusable Bash modules painlessly. Bashtion makes it easy to modularize existing code and write end-to-end tests.\n\n## Features\n\n* Makes it easy to modularize existing code bases\n* Provides an `import` function to easily use other modules without worrying about things like import cycles\n* Contains a test framework, useful for end-to-end testing (and it is used to [test Bashtion](tests/) itself)\n* Colorized stack traces for debugging\n* Includes a built-in logger and other common utilities\n\nBashtion is geared toward use in production environments where code reuse and finding bugs becomes critical for success.\nThis framework is still under development, so if you have any suggestions, feel free to [make an issue](https://github.com/JohnStarich/bashtion/issues/new)!\n\n## Try it\n\nRun the following command in your shell to try it out.\n\n```bash\nsource \u003c(curl -fsSL -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/JohnStarich/bashtion/releases/latest | grep browser_download_url | cut -d '\"' -f 4 | xargs curl -fsSL)\n```\n\nThe above script checks for the latest stable release and then sources it. Please note that try-bashtion.sh is not recommended for production builds.\n\n## Getting Started\n\nTo use Bashtion, simply source `bashtion.sh` in the root of this repository. You must be using at least Bash 4.\n\nInclude this in a script or use it in your `~/.bash_profile`. Here's an example start script:\n\n```bash\n#!/usr/bin/env bash\nsource \"$WORKSPACE/bashtion/bashtion.sh\"\n\nimport utils/logger\n\nlogger.info 'Hello world!'\n```\n\nAfter sourcing the `bashtion.sh` script, you're good to go! Both `utils/logger` and `utils/modules` are imported by default so you can get to the good stuff right away.\n\n## Writing your own modules\n\nYou can create your very own reusable modules!\n\nFor example, this one simply checks if your internet works `./modules/network/internet.sh`:\n\n```bash\n# Use included retry module\nimport utils/retrier\n\nfunction internet.status() {\n    retry curl http://google.com\n}\n```\n\nThe `import` function prevents import cycles and can be used as a drop-in replacement for `source`.\n\nTo use shorter import paths, you can register directories like `./modules` as an import path.\nThis start script registers `./modules` and calls our internet status checker:\n\n```bash\n#!/usr/bin/env bash\n# Run Bashtion's startup script\nsource \"$WORKSPACE/bashtion/bashtion.sh\"\n# Register your module\nmodules.register_import_path \"$PWD/modules\"\n\n# Finally, import and run it!\nimport network/internet\n\ninternet.status\n```\n\n## Writing your own tests\n\nTests are as simple as importing `test/assert` and calling `assert.stats` at the end of your tests.\n\nCheck out this simple test suite:\n\n```bash\nimport test/assert\nimport test/test\nimport utils/retrier\n\n\ntest.start \"Simple test\"\n\nassert echo hello world!\nassert.true echo hey!\n\nassert.false ls /missing\n\nassert.equal 'expected' \"$(echo expected)\"\nassert.not_equal 'unexpected' \"$(echo surprise!)\"\n\n# done! let's print our test results.\ntest.stats\n# Output:\n#\n# [ INFO] Test Results:\n# [ INFO] 4/4 (100%) tests passed. 0 tests failed.\n# [ INFO] All tests passed.\n```\n\nFor a more comprehensive test runner, check out the one we use to test Bashtion [here](test.sh).\n\n## How do I poke around this library?\n\nEvery module has its own file inside of [lib](lib/) or its subdirectories. If you see a module you want in there, just import it using its relative path from `lib`. The retrier is located in `./lib/utils/retrier.sh` so you would run `import utils/retrier`.\n\nIf you want to find out which commands are available for a module, the easiest way is to run the function with that module's name.\nFor example, run `logger` and it will print out all available logger commands like `logger.info` and `logger.error`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnstarich%2Fbashtion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnstarich%2Fbashtion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnstarich%2Fbashtion/lists"}