Use $retval rather than echo

This allows us to avoid spawning subshells all over.