If all this is doing is exiting on failure why not use "set -e" to let bash do that check for you?