bash function that works for both scalar and array types:
definition
has_declare() { # check if variable is set at all local "$@" # inject 'name' argument in local scope &>/dev/null declare -p "$name" # return 0 when var is present } invocation
if has_declare name="vars_name" ; then echo "variable present: vars_name=$vars_name" fi