Last active
April 9, 2018 18:11
-
-
Save slayerlab/7af63e3118f7884b60b3a5046c0a0b47 to your computer and use it in GitHub Desktop.
[PoC, bash] check element existence into array
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
#!/bin/bash | |
function check_v | |
{ | |
local v k="$1" | |
shift | |
for v; do [[ "$v" == "$k" ]] && | |
return 0; | |
done | |
return 1 | |
} | |
function main | |
{ | |
local element="$1" | |
array=("slayer" "krisiun" "celtic frost" "venom") | |
check_v "$element" "${array[@]}" | |
echo $? | |
} | |
main "$1" | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set -x