{"id":13653984,"url":"https://github.com/bash-bastion/bash-core","last_synced_at":"2025-08-13T08:32:27.776Z","repository":{"id":45679517,"uuid":"421612386","full_name":"bash-bastion/bash-core","owner":"bash-bastion","description":"Core functions for any Bash program.","archived":false,"fork":false,"pushed_at":"2023-09-30T04:26:26.000Z","size":2946,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T08:22:41.581Z","etag":null,"topics":["basalt","bash","shell"],"latest_commit_sha":null,"homepage":"https://bash-bastion.github.io/bash-core/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bash-bastion.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}},"created_at":"2021-10-26T23:21:01.000Z","updated_at":"2024-05-01T13:20:47.000Z","dependencies_parsed_at":"2023-02-14T08:35:14.995Z","dependency_job_id":"3b47fb34-e1e1-4232-860c-46ad44acbb68","html_url":"https://github.com/bash-bastion/bash-core","commit_stats":null,"previous_names":["bash-bastion/bash-core","hyperupcall/bash-core"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-bastion%2Fbash-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-bastion%2Fbash-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-bastion%2Fbash-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-bastion%2Fbash-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bash-bastion","download_url":"https://codeload.github.com/bash-bastion/bash-core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229749192,"owners_count":18118325,"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","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":["basalt","bash","shell"],"created_at":"2024-08-02T02:01:21.487Z","updated_at":"2025-08-13T08:32:27.759Z","avatar_url":"https://github.com/bash-bastion.png","language":"Shell","funding_links":[],"categories":["General use"],"sub_categories":["Libraries"],"readme":"# bash-core\n\nCore functions for any Bash program\n\n## Summary\n\nThe following is a brief overview of the available functions. See [api.md](./docs/api.md) for more details\n\n### trap\n\nAdd or remove multiple functions at a time to any set of signals. Without these, it is impossible to trap a signal without erasing a previous one\n\n- `core.trap_add`\n- `core.trap_remove`\n\n### shopt\n\nEnable or disable a shell option. Enabling a shell option adds it to a hidden stack. When that shell option is no longer needed, it should be removed by popping it from the stack\n\n- `core.shopt_push`\n- `core.shopt_pop`\n\n### err\n\nIt can look redundant (compared to `if ! fn; then :; fi`) to define error functions, but it can help make errors a bit more safe in larger applications, since you don't have to worry about a caller forgetting to `if ! fn` or `fn ||` (and terminating the script if `set -e`). It also makes it easier to communicate specific error codes and helps separate between calculated / expected errors and unexpected errors / faults\n\n- `core.err_set`\n- `core.err_clear`\n- `core.err_exists`\n\n### print\n\n- `core.print_stacktrace`\n- `core.print_fatal`\n- `core.print_error`\n- `core.print_warn`\n- `core.print_info`\n- `core.print_debug`\n\nThe function `core.print_stacktrace` prints the stack trace. It is recommended to use this with `core.trap_add` (see [example](./docs/api.md#coreprint_stacktrace))\n\nFollowing is a `core.print_stacktrace` example:\n\n```txt\nStacktrace:\n  in core.stacktrace_print (/tmp/test.sh:0)\n  in err_handler (/tmp/test.sh:36)\n  in fn3 (/tmp/test.sh:48)\n  in fn2 (/tmp/test.sh:53)\n  in fn (/tmp/test.sh:57)\n```\n\n## Installation\n\nUse [Basalt](https://github.com/hyperupcall/basalt), a Bash package manager, to add this project as a dependency\n\n```sh\nbasalt add hyperupcall/bash-core\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbash-bastion%2Fbash-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbash-bastion%2Fbash-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbash-bastion%2Fbash-core/lists"}