Bash - Utility Script
Description
A helper/utility script to be imported by other scripts.
Intended to hold very common functionality (that's surprisingly not built into bash) such as string upper/lower, and checking current user value, and prompts of yes/no user input.
Using the Script
First, copy the utils.sh
script into your desired project folder.
Next, call it in a different script with the line . $(dirname ${0})/<relative_path_to_script_file>
. Note that this
should be near the top of the file.
For example, if both utils.sh
and the calling script are in the same directory, then the syntax would be:
. $(dirname ${0})/utils.sh
At this point, you should have full functionality of the utils.sh
file.
Terminal Current Directory
On importing this script, it will automatically change the terminal to the location of the script's directory. This is to keep relative path handling the same, regardless of calling location.
Terminal location resets on script end.
References
See documents/references.md
.