{"id":45136996,"url":"https://github.com/octivi/bash-boilerplate","last_synced_at":"2026-02-20T00:05:05.761Z","repository":{"id":187386579,"uuid":"613408918","full_name":"octivi/bash-boilerplate","owner":"octivi","description":"Template for writing better Bash scripts","archived":false,"fork":false,"pushed_at":"2026-02-12T11:44:17.000Z","size":76,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-12T20:12:36.374Z","etag":null,"topics":["bash","bash-boilerplate","bash-script","boilerplate","command-line"],"latest_commit_sha":null,"homepage":"","language":null,"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/octivi.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-13T14:12:52.000Z","updated_at":"2026-02-12T11:44:21.000Z","dependencies_parsed_at":"2025-02-17T19:30:19.039Z","dependency_job_id":"8f4be9de-813c-4b0d-8cc2-31f4b3ddb5f1","html_url":"https://github.com/octivi/bash-boilerplate","commit_stats":null,"previous_names":["octivi/bash-boilerplate"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/octivi/bash-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octivi%2Fbash-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octivi%2Fbash-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octivi%2Fbash-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octivi%2Fbash-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octivi","download_url":"https://codeload.github.com/octivi/bash-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octivi%2Fbash-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29637398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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","bash-boilerplate","bash-script","boilerplate","command-line"],"created_at":"2026-02-20T00:05:05.162Z","updated_at":"2026-02-20T00:05:05.742Z","avatar_url":"https://github.com/octivi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Octivi Bash Boilerplate (OBB)\n\n[![GitHub Releases](https://img.shields.io/github/v/release/octivi/bash-boilerplate?sort=semver)](https://github.com/octivi/bash-boilerplate/releases)\n[![License: MIT](https://img.shields.io/github/license/octivi/bash-boilerplate)](https://choosealicense.com/licenses/mit/)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org/)\n[![Semantic Versioning](https://img.shields.io/badge/SemVer-2.0.0-blue)](https://semver.org/spec/v2.0.0.html)\n\n\u003e If you are writing a script that is more than 100 lines long, or that uses non-straightforward control flow logic, you\n\u003e should rewrite it in a more structured language now. --\n\u003e [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html)\n\n## Octivi Bash Boilerplate (OBB)\n\nOctivi Bash Boilerplate (OBB) is a lightweight starting point for Bash scripts that promotes consistent structure and\nsafe defaults. With ready-to-use helpers and auto-generated documentation, it helps you ship maintainable CLI utilities\nfaster and with fewer surprises.\n\n## Octivi Bash Boilerplate (OBB) Header\n\nOctivi Bash Boilerplate (OBB) Header is a minimalistic version of the Bash boilerplate for use in scripts.\nCopy and paste this code at the beginning of your Bash script files.\n\n## Key features\n\n- Enforces [Unofficial Bash \"Strict Mode\"](http://redsymbol.net/articles/unofficial-bash-strict-mode/) to reduce\n  hard-to-track runtime errors\n- Enables verbose diagnostics through the `DEBUG` environment variable\n- Honors the `NO_COLOR` ([disabling colors](https://no-color.org/)) and `FORCE_COLOR` environment variables and\n  supports ANSI colors out of the box\n- Exposes logging helpers for uniform, readable output\n- Generates `-h` help text from inline comments, so documentation stays close to the code\n- Handles option parsing through\n  [POSIX getopts](https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash/14203146#14203146)\n  for predictable CLI behavior\n\n## Requirements\n\n- Bash 4.4 or newer\n\n## Install\n\n### Manual\n\nDownload, verify checksums, and install all OBB files together:\n\n```bash\n# or use releases/latest/download/... URLs if you always want the latest release\ncurl -fsSLO https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate \\\n  \u0026\u0026 curl -fsSLO https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate-header \\\n  \u0026\u0026 curl -fsSLO https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate-update \\\n  \u0026\u0026 curl -fsSL https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate.sha256 \\\n  | sha256sum -c - \\\n  \u0026\u0026 curl -fsSL https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate-header.sha256 \\\n  | sha256sum -c - \\\n  \u0026\u0026 curl -fsSL https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/octivi-bash-boilerplate-update.sha256 \\\n  | sha256sum -c - \\\n  \u0026\u0026 sudo install -m 0644 octivi-bash-boilerplate /usr/local/share/octivi-bash-boilerplate \\\n  \u0026\u0026 sudo install -m 0644 octivi-bash-boilerplate-header /usr/local/share/octivi-bash-boilerplate-header \\\n  \u0026\u0026 sudo install -m 0755 octivi-bash-boilerplate-update /usr/local/share/octivi-bash-boilerplate-update \\\n  || { echo \"Checksum verification failed; aborting installation.\" \u003e\u00262; exit 1; }\n```\n\n### Ansible\n\nInstall all OBB files with checksum verification:\n\n```yaml\n- name: \"Install Octivi Bash Boilerplate files\"\n  ansible.builtin.get_url:\n    # or use releases/latest/download/... URLs if you always want the latest release\n    url: \"https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/{{ item.name }}\"\n    dest: \"/usr/local/share/{{ item.name }}\"\n    owner: \"root\"\n    group: \"root\"\n    mode: \"{{ item.mode }}\"\n    checksum: \"sha256:https://github.com/octivi/bash-boilerplate/releases/download/v1.1.0/{{ item.name }}.sha256\"\n  loop:\n    - { name: \"octivi-bash-boilerplate\", mode: \"0644\" }\n    - { name: \"octivi-bash-boilerplate-header\", mode: \"0644\" }\n    - { name: \"octivi-bash-boilerplate-update\", mode: \"0755\" }\n  register: \"__obb_download\"\n  until: __obb_download is succeeded\n  retries: 5\n  delay: 2\n```\n\n## Quick start: use OBB in scripts (with markers)\n\nThe easiest workflow is to keep OBB in a marked block and let\n`octivi-bash-boilerplate-update` inject/update the content for you.\n\n### Header variant (minimal)\n\nUse this when you only need strict mode and base constants.\n\n```bash\n#!/usr/bin/env bash\n\n# \u003e\u003e\u003e OBB:BEGIN variant=header\n# \u003c\u003c\u003c OBB:END\n\nmain() {\n  echo \"Hello from header mode\"\n}\n\nmain \"$@\"\n```\n\nThen update the marked block:\n\n```bash\n/usr/local/share/octivi-bash-boilerplate-update ./your-script\n```\n\n### Full variant (helpers + logging + checks)\n\nUse this when you want OBB helper functions like `print`, `error`, `die`, `require_command`, etc.\n\nImportant: place the full OBB marker block at the end of the script and keep your own logic above it.\n\n```bash\n#!/usr/bin/env bash\n#/ Usage: your-script [OPTIONS]\n#/ Example:\n#/   your-script --help\n\nmain() {\n  print \"Hello from full mode\"\n}\n\n# \u003e\u003e\u003e OBB:BEGIN variant=full\n# \u003c\u003c\u003c OBB:END\n```\n\nThen update the marked block:\n\n```bash\n/usr/local/share/octivi-bash-boilerplate-update ./your-script\n```\n\nTo pin the inserted block to a specific release:\n\n```bash\n/usr/local/share/octivi-bash-boilerplate-update -u 1.1.1 ./your-script\n```\n\n## Update inlined OBB blocks\n\nUse `octivi-bash-boilerplate-update` to update scripts where OBB was copy-pasted (not sourced).\n\n```bash\n/usr/local/share/octivi-bash-boilerplate-update ./script-a ./script-b\n/usr/local/share/octivi-bash-boilerplate-update -u 1.1.1 ./script-a\n/usr/local/share/octivi-bash-boilerplate-update --variant header ./script-a ./script-b\n```\n\n`--variant` accepts `full` or `header`. Without `--variant`, each marked block must define\n`variant=full|header` in its `# \u003e\u003e\u003e OBB:BEGIN ...` marker.\n\nWhen `-u/--use` is set, the script downloads release assets and verifies their `.sha256` checksums before updating any\ntarget files.\n\nIf a target file has no OBB markers, it is skipped with a warning.\n\nThe updater writes explicit markers around embedded blocks:\n\n```bash\n# \u003e\u003e\u003e OBB:BEGIN variant=full source=github version=v1.1.1\n...\n# \u003c\u003c\u003c OBB:END\n```\n\n## Projects that use Octivi Bash Boilerplate\n\n- [BorgBackup Wrapper](https://github.com/octivi/borg-backup-wrapper) - a wrapper around the deduplicating archiver\n  [BorgBackup](https://www.borgbackup.org/) that streamlines everyday tasks across multiple repositories.\n\n## How to test on a specific Bash version\n\nThe easiest way is to use Docker, for example to test Bash 3.2:\n\n```bash\ndocker run -it --rm -v \"$PWD\":/work -w /work bash:3.2 bash\n```\n\n## Other resources\n\n[Awesome Bash - A curated list of delightful Bash scripts and resources](https://github.com/awesome-lists/awesome-bash)\n\n### Style guides\n\n- [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html)\n- [Bash FAQ](https://mywiki.wooledge.org/BashFAQ)\n- [Pure Bash Bible](https://github.com/dylanaraps/pure-bash-bible)\n- [Unix shell script tactics — best practices style guide](https://github.com/SixArm/unix-shell-script-tactics)\n- [Shell Scripts Matter](https://dev.to/thiht/shell-scripts-matter)\n- [Bash tips: Colors and formatting](https://misc.flogisoft.com/bash/tip_colors_and_formatting)\n\n### Boilerplates\n\n- [BASH3 Boilerplate (b3bp)](https://bash3boilerplate.sh/)\n- \u003chttps://github.com/xwmx/bash-boilerplate\u003e\n- \u003chttps://github.com/oxyc/bash-boilerplate\u003e\n- \u003chttps://github.com/ralish/bash-script-template\u003e\n- \u003chttps://github.com/andrei-pavel/bash-boilerplate\u003e\n\n### Tools\n\n- [ShellCheck](https://www.shellcheck.net/)\n- [Shellharden](https://github.com/anordal/shellharden)\n\n## License\n\nAll content is provided under the terms of [The MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctivi%2Fbash-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctivi%2Fbash-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctivi%2Fbash-boilerplate/lists"}