version.sh: Fix in-tree case and allow external variables