Created
January 11, 2014 21:44
-
-
Save coderofsalvation/8377369 to your computer and use it in GitHub Desktop.
check if variable is array, returns 0 on success, 1 otherwise
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
# check if variable is array, returns 0 on success, 1 otherwise | |
# @param mixed | |
is_array() | |
{ #detect if arg is an array, returns 0 on sucess, 1 otherwise | |
[ -z "$1" ] && return 1 | |
if [ -n "$BASH" ]; then | |
declare -p ${1} 2> /dev/null | grep 'declare \-a' >/dev/null && return 0 | |
fi | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment