diff options
author | Thomas Bächler <thomas@archlinux.org> | 2011-01-27 11:19:01 +0100 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2011-01-27 11:19:01 +0100 |
commit | 39c1bf5ea0a3bce6ffcd8af79f0b924732a5b509 (patch) | |
tree | 528350e1b8f909306f0ebd593e6fdb531ca92980 /functions | |
parent | ef74507563bf994d6abb2621ebd3b6f6818b6b2f (diff) | |
download | initscripts-39c1bf5ea0a3bce6ffcd8af79f0b924732a5b509.tar.xz |
Fix run_hook and add_hook definitions.
This patch does 3 things:
1) Use declare -fr instead of -r, as -r does not affect functions.
2) Make sure everything is only defined once, as you cannot redefine a read-only function.
3) Fix indentation.
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -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() { |