aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2009-08-05 10:17:00 -0700
committerAaron Griffin <aaronmgriffin@gmail.com>2009-08-05 10:17:00 -0700
commitf3a1103e58c341d5bb42bc889549fef44d685729 (patch)
treec98fea6fae73dfabb2b29045484b4a9af0cf0186 /functions
parent602eb29574318edebd6cf3c9e82d97c504a6dd13 (diff)
downloadinitscripts-f3a1103e58c341d5bb42bc889549fef44d685729.tar.xz
Enable in_array for prefixed daemons
Previous code has issues with ! and @ prefixed DAEMONS Original-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'functions')
-rw-r--r--functions18
1 files changed, 11 insertions, 7 deletions
diff --git a/functions b/functions
index 7c8e4df..0f333d4 100644
--- a/functions
+++ b/functions
@@ -159,13 +159,17 @@ status() {
# 1 - not found
# Copied from makepkg
in_array() {
- local needle=$1; shift
- [ -z "$1" ] && return 1 # Not Found
- local item
- for item in "$@"; do
- [ "$item" = "$needle" ] && return 0 # Found
- done
- return 1 # Not Found
+ local needle=$1; shift
+ [ -z "$1" ] && return 1 # Not Found
+ local item
+ for item in "$@"; do
+ local c="${item:0:1}"
+ if [ "$c" == "!" -o "$c" == "@" ]; then
+ item="${item:1}"
+ fi
+ [ "$item" = "$needle" ] && return 0 # Found
+ done
+ return 1 # Not Found
}
# daemons: