aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions35
1 files changed, 19 insertions, 16 deletions
diff --git a/functions b/functions
index 718d8c4..7700709 100644
--- a/functions
+++ b/functions
@@ -312,22 +312,25 @@ read_crypttab() {
# Declare add_hook and run_hook as read-only to prevent overwriting them.
# Too bad we cannot do the same thing with hook_funcs
-declare -A hook_funcs
-
-add_hook() {
- [[ $1 && $2 ]] || return 1
- hook_funcs["$1"]+=" $2"
-}
-
-run_hook() {
- [[ $1 ]] || return 1
- local func
- for func in ${hook_funcs["$1"]}; do
- "${func}"
- done
-}
-
-declare -r add_hook run_hook
+if [[ $RC_FUNCTIONS_HOOK_FUNCS_DEFINED -ne 1 ]]; then
+ declare -A hook_funcs
+
+ add_hook() {
+ [[ $1 && $2 ]] || return 1
+ hook_funcs["$1"]+=" $2"
+ }
+
+ run_hook() {
+ [[ $1 ]] || return 1
+ local func
+ for func in ${hook_funcs["$1"]}; do
+ "${func}"
+ done
+ }
+
+ declare -fr add_hook run_hook
+ declare -r RC_FUNCTIONS_HOOK_FUNCS_DEFINED=1
+fi
# Function for setting console font if required
set_consolefont() {