gl-common.bash aims to improve writing of Bash scripts and provides several useful functions for scripting.
Key features:
- Standardized user interactions for outputs and inputs
- Variable manipulation
- Handle portable basic options for scripts
- Simplifies use of shFlags
- Easy documentation of your scripts with Markdown
And it has many free examples.
- Download the file or clone the git repository
- Then, load the file in your script with:
# Load gl-common.bash
readonly MYAPP_DIR=$(dirname "$(echo "$(readlink -f "$0")" | sed -e 's,\\,/,g')")
. "${MYAPP_DIR}/gl-common.sh" MYAPP_
if [[ $? > 0 ]]; then echo "Error when loading file '${MYAPP_DIR}/gl-common.sh'"; exit 1; fi
You may want to replace MYAPP_
with your very own prefix.
In your script, put:
# Load gl-common.bash from a remote URL
eval "$(curl -sL https://raw.githubusercontent.com/golflima/gl-common.bash/master/gl-common.sh)"
if [[ $? > 0 ]]; then echo "Error when loading gl-common.sh"; exit 1; fi
gl_common_set_var_prefix MYAPP_
You may want to replace MYAPP_
with your very own prefix.
[View gl-common.bash scripting reference.](Scripting Reference.md)
gl-common.bash is published under the terms of GNU Lesser General Public License v3, see the LICENSE file.
Although the GNU LGPLv3 does not require you to share any modifications you make to the source code, you are very much encouraged and invited to contribute back your modifications to the community, preferably in a Github fork, of course.