[arch-projects] [initscripts] [PATCH 11/20] Deprecate in_array()

Kurt J. Bosch kjb-temp-2009 at alpenjodel.de
Sun Jul 10 13:26:11 EDT 2011


in_array() strips '@' and therefore the name is missleading.
For checking DAEMONS, ck_autostart() should be used.
---
 functions  |    7 ++++++-
 rc.sysinit |    2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/functions b/functions
index 6efcd52..d594c3e 100644
--- a/functions
+++ b/functions
@@ -162,10 +162,15 @@ status() {
 	return $ret
 }
 
+# This is deprecated!
+# It strips '@' and therefore the name is missleading.
+# For checking DAEMONS, ck_autostart() should be used!
+#
 #  usage : in_array( $needle, $haystack )
 # return : 0 - found
 #          1 - not found
 in_array() {
+	echo "WARNING: Call to deprecated function in_array() from $0" >&2
 	local needle=$1; shift
 	local item
 	for item; do
@@ -272,7 +277,7 @@ stop_all_daemons() {
 	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
diff --git a/rc.sysinit b/rc.sysinit
index 4132b8c..2ef85e6 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -174,7 +174,7 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
 fi
 
 # Check filesystems
-[[ -f /forcefsck ]] || is_in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f"
+[[ -f /forcefsck || " $(< /proc/cmdline) " =~ [[:blank:]]forcefsck[[:blank:]] ]] && FORCEFSCK="-- -f"
 declare -r FORCEFSCK
 run_hook sysinit_prefsck
 if [[ -x $(type -P fsck) ]]; then
-- 
1.7.1



More information about the arch-projects mailing list