2017-03-16 - starting a script

some time ago we had an issue on CI build machines. on test environment, failed builds did not fail. all CI did was to run a simple bash script – sth along these lines:

#!/bin/bash -ex
cd /build/path
cmake /source/dir
ninja
ctest

we double-checked that build errors failed the script locally, but not on our CI. after a bit of digging it turned out that CI is running scripts like this:

bash /path/to/ci/script

while we run these “the usual way”:

cd /path/to/ci
./script

difference? when source-running, bash-bang is ignored! :) this in turn means that stopping on error was not honored – the rest you already know.

answer? update your script:

#!/bin/bash
set -ex       # NOTE: changing shell settings inside the script, not bash-bang
cd /build/path
cmake /source/dir
ninja
ctest