Knowledge Base
Authentication is disabled (development mode).

Check if a Bash array contains a value

Edit

array bash contain contains element sh shell value

# $1 name of array, not working for "@"
# $2 value to be checked
inArray()
{
    local IFS="$separator"
    local __array="$1[*]"
    local __value=$2

    [[ "${IFS}${!__array}${IFS}" =~ "${IFS}${__value}${IFS}" ]]
}