You can still use set -e. If you have specific statement which you expect to fail, you simply need to catch the error state and "handle" it:
$ cat 454756.sh
#!/bin/bash
set -e
[[ 1 -eq 2 ]] || :
echo "Still got here!"
$ ./454756.sh
Still got here!
set -e will abort the script on any uncaught error condition. Otherwise you would not be able to use if statements.
# this also still works
set -e
if /bin/false; then
echo "nope"
else
echo "yep"
fi
The incantation || : is a succinct way to "eat" any error thrown by any command, which is handy when you're wanting to use set -e and have specific commands whose failure is perfectly okay.
Another way to do this is to unset -e before the command in question, and reset it afterward:
set -e
do_stuff
set +e
/bin/false
set -e
exit 1work?grep's that aren't returning correctly as well. Enablingset -eis a level of conformance that you're demanding of your script, so you're basically working against it rather than using its enforcements. Just my $0.02.