created hw-core bash libraries

will be traited as a git subtree
This commit is contained in:
Yehonal
2016-08-13 20:25:34 +02:00
parent 86fc3b01f4
commit ff6201921c
5 changed files with 17 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
# par 1: hook_name
function hwc_event_run_hooks() {
hook_name="HOOKS_MAP_$1"
read -r -a SRCS <<< ${!hook_name}
echo "Running hooks: $hook_name"
for i in "${SRCS[@]}"
do
$i # run registered hook
done
}
function hwc_event_register_hooks() {
hook_name="HOOKS_MAP_$1"
hooks=${@:2}
declare -g "$hook_name+=$hooks "
}