Fixes to build.sh to return proper error code