Skip to content

Commit dcdbe2d

Browse files
author
Wes Dean
committed
Add library support
1 parent d891d27 commit dcdbe2d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

shell_script_template.bash

+22-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717

1818
set -euo pipefail
1919

20-
2120
## @var SCRIPT_PATH
2221
## @brief path to where the script lives
2322
declare SCRIPT_PATH
2423
# shellcheck disable=SC2034
2524
SCRIPT_PATH="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P)"
2625

26+
## @var LIBRARY_PATH
27+
## @brief location where libraries to be included reside
28+
declare LIBRARY_PATH
29+
LIBRARY_PATH="${SCRIPT_PATH}/lib/"
2730

2831
## @var DEFAULT_WORD
2932
## @brief default value for the 'word' CLI parameter
@@ -127,6 +130,24 @@ main() {
127130
trap die ERR
128131

129132

133+
###
134+
### If there is a library directory (lib/) relative to the
135+
### script's location by default), then attempt to source
136+
### the *.bash files located there.
137+
###
138+
139+
140+
if [ -n "${LIBRARY_PATH}" ] \
141+
&& [ -d "${LIBRARY_PATH}" ] ; then
142+
for library in "${LIBRARY_PATH}"*.bash ; do
143+
if [ -e "${library}" ] ; then
144+
# shellcheck disable=SC1090
145+
. "${library}"
146+
fi
147+
done
148+
fi
149+
150+
130151
###
131152
### set values from their defaults here
132153
###

0 commit comments

Comments
 (0)