Created
May 8, 2012 10:35
-
-
Save nibalizer/2634139 to your computer and use it in GitHub Desktop.
bash thing i found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# usage : in_array( $needle, $haystack ) | |
# return : 0 - found | |
# 1 - not found | |
## | |
in_array() { | |
local needle=$1; shift | |
local item | |
for item in "$@"; do | |
[[ $item = $needle ]] && return 0 # Found | |
done | |
return 1 # Not Found | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment