replace [[ -v ]] by testing result of "declare -p"

For empty arrays, Bash's [[ -v ... ]] will return false. This is
not what we want here, so we test for an existing variable definition
using "declare -p".