I have a script which compile a program. This program first compiles the source code using configure && make commands, then runs some tests using make test. This script also uses set -e to catch errors.

Now, what I want to do is keep set -e set in the script and still continue running the script when make test encounters some errors. I have tried using make -k test to make the tests run even when it encounters errors, but it is caught by the set -e command and it is stopped.

I also know which tests are going to fail, so is there any way to tell the script to skip catching these errors.

make test || true


set -e
echo hello
make test || true
echo done

Will result in

make: *** No rule to make target `test'.  Stop.

In this case the failure was a missing rule (no Makefile :-)) but we can see the script continues.


set -e can be flipped with set +e.

set -e
configure && make
set +e
make test
  • Isn't there any other way to do it? As in more robust way? – Abhimanyu Saharan Jun 22 '16 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.