{"id":17152527,"url":"https://github.com/juan131/bash-libraries","last_synced_at":"2025-10-27T13:39:31.839Z","repository":{"id":49871644,"uuid":"170139419","full_name":"juan131/bash-libraries","owner":"juan131","description":"A set of useful Bash libraries","archived":false,"fork":false,"pushed_at":"2021-06-09T11:48:22.000Z","size":11,"stargazers_count":65,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T03:41:42.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juan131.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":"2019-02-11T14:08:41.000Z","updated_at":"2025-03-11T13:06:51.000Z","dependencies_parsed_at":"2022-09-17T16:21:38.120Z","dependency_job_id":null,"html_url":"https://github.com/juan131/bash-libraries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juan131%2Fbash-libraries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juan131%2Fbash-libraries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juan131%2Fbash-libraries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juan131%2Fbash-libraries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juan131","download_url":"https://codeload.github.com/juan131/bash-libraries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717226,"owners_count":21150387,"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":[],"created_at":"2024-10-14T21:43:51.900Z","updated_at":"2025-10-27T13:39:31.774Z","avatar_url":"https://github.com/juan131.png","language":"Shell","readme":"# bash-libraries\n\nA set of useful Bash libraries\n\n## Current libraries\n\n- [liblog.bash](https://github.com/juan131/bash-libraries/blob/master/lib/liblog.bash)\n- [libfs.bash](https://github.com/juan131/bash-libraries/blob/master/lib/libfs.bash)\n- [libos.bash](https://github.com/juan131/bash-libraries/blob/master/lib/libos.bash)\n\n## Use\n\nLoad the desired library on you Bash scripts as follows:\n\n```bash\n...\n. /dev/stdin \u003c\u003c\u003c \"$(curl -s https://raw.githubusercontent.com/juan131/bash-libraries/master/lib/liblog.bash)\"\n...\n```\n\n## Bash best practices\n\nHere you can find a series of tips when developing a Bash script:\n\n- Start your scripts with the proper shebang: `#!/bin/bash`.\n- Start each file with a description of its contents.\n- Use built-in options `set -o OPTION`:\n    - **errexit**: make your script exit when a command fails. Add `|| true` to allow a command to fail.\n    - **nounset**: make your script exit when using undeclared variables.\n    - **pipefail**: sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.\n    - **xtrace**: only for debugging.\n- Create a main function for scripts long enough to contain at least one other function.\n- Use `local` when declaring variables, unless there is reason to use `declare`.\n- Use `readonly` when defining \"read only\" constants.\n- Use `:-` for variables that could be undeclared.\n- Naming conventions:\n    - Only use uppercase on constants or when a variable is exported to the environment.\n    - Use underscore `_` instead of `-` to separate words. Do not use _camelCase_.\n    - Do not start variable names with special characters or numbers.\n- Use `. xxx.sh` instead of `source xxx.sh`.\n- Use `$()` over backticks.\n- Use `${var}` instead of `$var` when concatenating strings.\n- Double quote variables, no naked `$` signs.\n- Use `my_func() { ... }` instead of `function my_func { ... }`.\n- Use `\u0026\u0026` and `||` for simple conditionals.\n- Put `then;`, `do;`, etc. on the same line.\n- Use `[[` instead of `[`.\n- Prefer absolute paths.\n- Avoiding temporary files. Use process substitution (`\u003c()`) to transform commands output into sth that can be used as a filename:\n\n    ~~~bash\n    # Note that if any of the wget fails, and the diff succeed, this\n    # statement will success regarding of built-in options!\n    diff \u003c(wget -O - url1) \u003c(wget -O - url2)\n    ~~~\n\n- Warnings and errors should go to _STDERR_.\n- Use `bash -x myscript.sh` for debugging.\n\n\u003e Note: You can use [ShellCheck](https://www.shellcheck.net) to ensure your bash syntax does not contain any warning/error. Linters will be included on repositories to ensure every commit passes a series of checks.\n","funding_links":[],"categories":["others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuan131%2Fbash-libraries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuan131%2Fbash-libraries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuan131%2Fbash-libraries/lists"}