If you already assume bash, then you don’t need the “-v” option to the “test” builtin; just do
if [ "${foo+some_string}" = "" ]; then
echo "foo is unset"
fi
or, in your case: if test "${2+x}" = "" # i.e. if $2 is not set