diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2010-06-07 07:23:30 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2010-07-11 19:01:27 -0500 |
commit | 9c920cd09d1b0a9a53a4ac62981ed41431a610df (patch) | |
tree | c8e160111256834b22016a829835b35b84e19fa3 /functions | |
parent | 4300436822ac740888bce3d3dbbfe845e32b9305 (diff) |
Simplify in_array.
All that extra checking for the first character being @ is not needed,
simple parameter expansion will trim it off if it is there.
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -136,17 +136,13 @@ 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 - local c="${item:0:1}" - if [ "x$c" = "x@" ]; then - item="${item:1}" - fi - [ "$item" = "$needle" ] && return 0 # Found - done - return 1 # Not Found + [[ $2 ]] || return 1 + local needle=$1; shift + local item + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 + done + return 1 # Not Found } # daemons: |