[arch-projects] [initscripts] [PATCH 07/12] functions: Deprecate in_array(), Add replacement is_in_array()
* in_array() strips '@' and therefore the name is missleading. * For checking DAEMONS, ck_autostart() should be used. --- functions | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 11f8317..375efbf 100644 --- a/functions +++ b/functions @@ -164,10 +164,23 @@ status() { return 1 } -# usage : in_array( $needle, $haystack ) +# usage : is_in_array( $needle, $haystack ) # return : 0 - found # 1 - not found +# Note: For checking DAEMONS, ck_autostart() should be used! +is_in_array() { + local needle=$1; shift + local item + for item; do + [[ $item = $needle ]] && return 0 + done + return 1 # Not Found +} + +# This is deprecated! +# It strips '@' and therefore the name is missleading. in_array() { + echo "WARNING: Call to deprecated function in_array() from $0" >&2 local needle=$1; shift local item for item; do @@ -274,7 +287,7 @@ kill_everything() { for daemon in /run/daemons/*; do [[ -f $daemon ]] || continue daemon=${daemon##*/} - in_array "$daemon" "${DAEMONS[@]}" || stop_daemon "$daemon" + ck_autostart "$daemon" && stop_daemon "$daemon" done # Shutdown daemons in reverse order @@ -371,7 +384,7 @@ fsck_all() { FSCK_ERR=/dev/stdout FSCK_FD= FORCEFSCK= - [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f" + [[ -f /forcefsck ]] || is_in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f" run_hook "$1_prefsck" -- 1.7.1
participants (1)
-
Kurt J. Bosch