A bash functions library.
Bashlings are bash functions to be sourced in bash scripts. These functions
are a hold-out from earlier times, and should be a last resort. Prefer using
tools provided by a real bash framework.
- available-fd : Find first unused file descriptor
(fd) (for
bash< 4.1 (e.g. macOS)). - cecho : Colored Echo: output text in color.
- check-binary : Check for the presence of a binary in $PATH.
- download : Download content from a URL and write it
to
/dev/stdout. - in-list : Test if a value is in a list.
- is-array : Test if a variable is an array.
- is-url : Test if a string is a HTTP, HTTPS, FTP or FILE URL.
- join-array : Join an array contents with a string separator.
- process-options : Alternative getopt for functions.
- realpath-check : Resolve the real absolute path and check for its existence.
- realpath : Resolve the real absolute path.
- repeat-string : Repeat a string N times.
Import Biapy Bashlings in the project:
git submodule add \
'https://github.com/biapy/biapy-bashlings.git' \
'lib/biapy-bashlings'See Cloning for including submodules when cloning a repository.
Make use of a Biapy Bashlings' function (e.g. in-list) in a script stored in
src folder:
source "${BASH_SOURCE[0]%/*}/../lib/biapy-bashlings/src/in-list.bash"
in-list "${value}" "${example_list[@]}" && echo "Found."skeleton.bash is a skeleton of bash script implementation.
It includes option processing, --quiet and --verbose implementation
examples, and basic error messages.
- Bash Reference Manual: The reference for Bash syntax and functionalities.
- Bash FAQ: Frequently Asked Questions about Bash. This is a very good reference full of examples and recommendations.
- ShellCheck: ShellCheck is a shell script analysis tool. It provides recommendations on good coding practices and alert of shell scripts' pitfalls.
- shfmt:
shfmtis a code formatter for shell scripts. - Bash-it: Bash-it is a Oh My Zsh inspired collection of Bash commands and scripts for Bash 3.2+.
Awesome lists for bash:
Package managers for publishing bash scripts:
Other interesting resources:
- Shell Script Best Practices @ The Sharat's.
- Expanding Bash arrays safely with
set -u. - Writing a TUI in BASH @ GitHub.
- Shell Auto Completion in Linux @ Baeldung Linux.
Biapy Bashlings uses:
- shdoc for generating markdown documentation from code.
- ShellCheck for checking code quality.
- shfmt for formatting scripts and bats unit tests.
- Bats-core: Bash Automated Testing System for unit testing, with its helper libraries:
Biapy Bashlings uses these GitHub actions for Continuous Integration:
- Super-Linter for lint checks.
- Setup BATS testing framework unit-tests, with its helper action:
This library uses the bats library for unit-testing.
Clone the repository with the additional libraries:
git clone --recurse-submodules 'git@github.com:biapy/biapy-downloader'Update the submodules with:
git submodule update --remoteThe Makefile provides these rules:
- help : Display a short help message about the rules available in the
Makefile. - clean : Delete generated documentation in
doc/and remove functions list fromREADME.md. - format : format files using
shfmton*.bashfiles insrc/and*.batsfiles intest/. - check : check files for errors using
shellcheckon*.bashfiles insrc/. - test : run unit tests.
- doc : Generate documentation in
doc/usingshdoc. - readme : Update function list in
README.md. - all : All of the above.