diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index a3a5ab9..93a9884 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,6 +1,6 @@ #### MINIMAL-FUNCTION-SET BEGIN #### -## FUNC_BUILD=2016101901 +## FUNC_BUILD=2016102101 ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## To use in a program, define the following variables: @@ -922,6 +922,21 @@ function urlDecode { printf '%b' "${urlEncoded//%/\\x}" } +## Modified version of http://stackoverflow.com/a/8574392 +## Usage: arrayContains "needle" "${haystack[@]}" +arrayContains () { + local e + + if [ "$2" == "" ]; then + echo 1 && return 1 + fi + + for e in "${@:2}"; do + [[ "$e" == "$1" ]] && echo 0 && return 0 + done + echo 1 && return 1 +} + function GetLocalOS { __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG