{"id":18913686,"url":"https://github.com/kingsolomon1954/ksl-bash-lib","last_synced_at":"2026-02-03T08:01:14.845Z","repository":{"id":260542708,"uuid":"881596436","full_name":"KingSolomon1954/ksl-bash-lib","owner":"KingSolomon1954","description":"A library of re-usable bash functions","archived":false,"fork":false,"pushed_at":"2025-01-06T06:36:10.000Z","size":3024,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T05:33:35.180Z","etag":null,"topics":["bash","bash-scripting","library","shell","terminal"],"latest_commit_sha":null,"homepage":"https://kingsolomon1954.github.io/ksl-bash-lib/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KingSolomon1954.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-10-31T22:14:40.000Z","updated_at":"2025-01-06T06:36:13.000Z","dependencies_parsed_at":"2024-10-31T23:23:08.559Z","dependency_job_id":"ee81e281-0d6f-46bc-a86b-8865ede0cc3c","html_url":"https://github.com/KingSolomon1954/ksl-bash-lib","commit_stats":null,"previous_names":["kingsolomon1954/ksl-bash-lib"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/KingSolomon1954/ksl-bash-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KingSolomon1954%2Fksl-bash-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KingSolomon1954%2Fksl-bash-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KingSolomon1954%2Fksl-bash-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KingSolomon1954%2Fksl-bash-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KingSolomon1954","download_url":"https://codeload.github.com/KingSolomon1954/ksl-bash-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KingSolomon1954%2Fksl-bash-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29037723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T06:39:36.383Z","status":"ssl_error","status_checked_at":"2026-02-03T06:39:32.787Z","response_time":96,"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","bash-scripting","library","shell","terminal"],"created_at":"2024-11-08T10:08:34.573Z","updated_at":"2026-02-03T08:01:14.794Z","avatar_url":"https://github.com/KingSolomon1954.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!---\nComments here if needed.\n--\u003e\n\n\u003ch1 align=\"center\"\u003eKSL Bash Library\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.freeiconspng.com/img/2450\" title=\"Image from freeiconspng.com\"\u003e\u003cimg src=\"https://www.freeiconspng.com/uploads/blue-fire-17.png\" width=\"40\" alt=\"Blue Fire\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nA collection of useful Bash functions that simplify writing scripts.\n\u003c/p\u003e\n\n---\n\n[![Build](https://img.shields.io/github/actions/workflow/status/kingsolomon1954/ksl-bash-lib/build.yml)](https://github.com/kingsolomon1954/ksl-bash-lib/actions/workflows/build.yml)\n[![Version](https://img.shields.io/github/v/release/kingsolomon1954/ksl-bash-lib)](https://github.com/kingsolomon1954/ksl-bash-lib/releases)\n\n## Features\n\n- **libArrays** - simplify handling of indexed and associative arrays\n- **libColor** - consistent use of color\n- **libEnv** - useful functions to manipulate PATH-like environment variables\n- **libError** - functions that support error passing\n- **libFiles** - useful functions to manipulate directory and file names\n- **libStdOut** - functions for consistent printing to stdout and stderr\n- **libStrings** - useful functions to manipulate strings\n- no calls to external utilities (such as sed or tr)\n\nSee the library documentation here:  [Github Pages](https://kingsolomon1954.github.io/ksl-bash-lib)\n\n## Prerequisites\n\n- no additional dependencies\n- all functions use only shell intrinsics, except for\n  libColors::ksl::isColorCapable() which calls `tput`, and\n  libError::ksl::epSet() which calls `date`.\n- tested against bash 5.2\n  \n## Usage\n\nSetup environment variable `KSL_BASH_LIB` to where you installed KSL\nBash library.\n\nThen, in scripts that you write:\n\n```bash\n#!/usr/bin/env bash\n# Bring in desired parts of KSL Bash library\nsource \"${KSL_BASH_LIB}\"/libColors.bash\nsource \"${KSL_BASH_LIB}\"/libStdOut.bash\n```\n\n- all KSL Bash library functions use `ksl::` as a prefix, e.g.,\n  `ksl::isInteger`\n\n- library documentation is available here on \n  [Github Pages](https://kingsolomon1954.github.io/ksl-bash-lib)\n  as well as included with the installed package in\n  `$KSL_BASH_LIB/docs/site/index.html`.\n\n## Installation\n\nKSL Bash library is installed by one of the following methods.\nThen set KSL_BASH_LIB to where you placed it.\n\n### Via GitHub Release \n\n1. Grab the latest release from here:\n\nhttps://github.com/KingSolomon1954/ksl-bash-lib/releases\n\nDownload the ksl-bash-lib-x.y.z.tgz file.\n\n2. Untar it to a location of your choosing.\n\n``` bash\ncd $HOME/bin\ntar -xzf ~/downloads/ksl-bash-lib-x.y.z.tgz\n```\n\n3. Setup environment variable to point to it.\n\n``` bash\nexport KSL_BASH_LIB=$HOME/bin/ksl-bash-lib-x.y.z\n```\n\n4. Examine docs\n\n``` bash\nfirefox $HOME/bin/ksl-bash-lib-x.y.z/docs/index.html\n```\n\n### Via git clone\n\n1. Clone the repo\n\n``` bash\ngit clone https://github.com/KingSolomon1954/ksl-bash-lib.git $HOME/dev/ksl-bash-lib\n```\n\n2. Setup environment variable to point to it.\n\n``` bash\nexport KSL_BASH_LIB=$HOME/dev/ksl-bash-lib/lib\n```\n\n3. Examine docs\n\n``` bash\nfirefox $HOME/dev/ksl-bash-lib/docs/site/index.html\n```\n\n## Developing the KSL Bash Library\n\nThis section till the end of the file are relevant only to\ndeveloping the KSL Bash library.\n\n### Prerequisites for Development\n\n- GNU Makefile\n- Podman or Docker\n- Typical Linux command line utilities\n\n### Containerized Tools\n\n- Uses containers for build tools where it makes sense\n  - for doc generation\n  - for static analysis via shellcheck\n- Supports Docker or Podman, prefers Podman over Docker if found\n- Containers mount local host workspace, no copying into container\n\n### Folder Layout\n\n**Top Level View**\n\n    ├── lib\n    ├── test\n    ├── docs\n    ├── tools\n    ├── etc\n    ├── Makefile\n    ├── version\n    └── Readme.md\n\n**Two Level View**\n\n    ├── Makefile\n    ├── Readme.md\n    ├── version\n    ├── lib\n    │  └── ...\n    ├── test\n    │  ├── ...\n    │  └── unit-test.mak\n    ├── docs\n    │  ├── src\n    │  ├── site\n    │  └── docs.mak\n    ├── tools\n    │  ├── bash-unit\n    │  ├── shdoc\n    │  └── submakes\n    └── etc\n       ├── examples\n       ├── License\n       └── todo.txt\n\nGenerally conforms to\n[PitchFork](https://github.com/vector-of-bool/pitchfork) project layout.\n\n## Example Usages\n\n``` bash\nmake help\nKSL Bash Library\n-------------- Targets --------------\n\nall                   - Build the repo\ndocs                  - Builds all the docs\ndocs-clean            - Deletes generated docs\ndocs-publish          - Update ./docs/site with ./_build/docs/site and checkin to Git\ndocs-shdoc            - Generates only bash API docs\ndocs-sphinx           - Generates only Sphinx docs\n\u003cfilepath\u003e.sta        - Runs Bash static analysis on given file\nhelp                  - Displays help information and targets\nstatic-analysis-clean - Deletes Bash static analysis artifacts\nstatic-analysis       - Runs Bash static analysis against repo\nunit-test             - runs unit tests\nunit-tests            - runs unit tests\n```\n\n### Run Unit Tests\n\n``` bash\nmake\n# or\nmake unit-test\n\n```\n\n### Unit Testing\n\n- Unit tests are kept separate from source code\n- Uses [bash_unit](https://github.com/pgrange/bash_unit)\n- bash_unit is installed within this repo\n\n### Build and Examine the Documentation\n\n``` bash\nmake docs\nfirefox _build/site/index.html\n```\n\n### Versioning\n\n- Single version file in project root\n- All built artifacts obtain version information from this one file\n- Auto-documentation and containers use this version file\n- Semantic versioning\n\n``` bash\ncat version\n1.0.0\n```\n\n### Static Code Analysis\n\nStatic code analysis can be performed against all source code in the\nlibrary at once or against a single file. Underlying tool is a\ncontainerized [shellcheck](https://github.com/koalaman/shellcheck).\n\nThe following makefile targets are available:\n\n    static-analysis       - Runs Bash static analysis against library\n    static-analysis-clean - Deletes Bash static analysis artifacts\n    \u003cfilepath\u003e.sta        - Runs Bash static analysis on given file\n\nFind results in `_build/static-analysis/results.txt`.\n\n``` bash\nmake static-analysis\nless _build/static-analysis/results.txt\n#\n# Or for a single file\n#\nmake lib/libStrings.sta\n\n```\n\n### GitHub Workflows\n\nFour workflows manage this repo.\n\n1. build.yml - builds on any push\n2. release.yml - manually triggered when a release is desired\n3. shared-build.yml - performs both build and release activities\n4. deploy-gh-pages.yml - updates GitHub pages after a release\n\n### Documentation Generation\n\n- Uses [Sphinx](https://www.sphinx-doc.org/) with\n  [read-the-docs](https://sphinx-rtd-theme.readthedocs.io/en/stable/index.html)\n  theme\n- [shdoc](https://github.com/reconquest/shdoc/) generates library API from source code\n- [pandoc](https://pandoc.org/) for intermediate document conversions\n\n\n#### Building the Docs\n\nFrom top level folder, invoke:\n\n```bash\nmake docs\nfirefox _build/site/index.html\n```\n\n#### Pubishing the Docs\n\nWhen satisfied with the generated site docs, the release workflow\nwill invoke this makefile target:\n\n```bash\nmake docs-publish\n```\n\nThe generated static website sitting in `_build/site`, is copied over to\nthe `docs/site` folder and checked-in to Git. A follow-on workflow kicks\nin and publishes `docs/site` folder to the actual GitHub Pages\nwebsite. The `docs/site` folder is hard coded into the\n`deploy-gh-pages.yml` GitHub action.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingsolomon1954%2Fksl-bash-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingsolomon1954%2Fksl-bash-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingsolomon1954%2Fksl-bash-lib/lists"}