From c773ac66da5006f39560fc45c0a22f5e1e47bee9 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Aug 2009 15:11:19 +0200 Subject: [PATCH] don't ignore prefixes in in_array --- functions | 11 ++++++++++- rc.shutdown | 2 +- rc.single | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 96903b9..ef35983 100644 --- a/functions +++ b/functions @@ -141,10 +141,19 @@ status() { # Copied from makepkg in_array() { local needle=$1; shift + local needle2=$needle [ -z "$1" ] && return 1 # Not Found local item for item in "$@"; do - [ "$item" = "$needle" ] && return 0 # Found + if [ "${item:0:1}" == "!" ]; then + needle2="!${needle}" + elif [ "${item:0:1}" == "@" ]; then + needle2="@${needle}" + else + needle2="${needle}" + fi + + [ "$item" = "$needle2" ] && return 0 # Found done return 1 # Not Found } diff --git a/rc.shutdown b/rc.shutdown index ef13dec..ad45969 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -26,7 +26,7 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then # Find daemons NOT in the DAEMONS array. Shut these down first if [ -d /var/run/daemons ]; then for daemon in $(/bin/ls -1t /var/run/daemons); do - if ! in_array $daemon ${DAEMONS}; then + if ! in_array $daemon ${DAEMONS[@]]}; then stop_daemon $daemon fi done diff --git a/rc.single b/rc.single index af2ae16..426a513 100755 --- a/rc.single +++ b/rc.single @@ -10,7 +10,7 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then # Find daemons NOT in the DAEMONS array. Shut these down first if [ -d /var/run/daemons ]; then for daemon in $(/bin/ls -1t /var/run/daemons); do - if ! in_array $daemon ${DAEMONS}; then + if ! in_array $daemon ${DAEMONS[@]]}; then stop_daemon $daemon fi done -- 1.6.4