>>190
! ret=foo
echo $?

or

if ret=$(foo); then
echo "truthy" "$ret" "$?"
else
echo "falsy" "$ret" "$?"
fi