set -euo pipefail
This addresses the pipeline case you mention and also notices use of unitialized variables.
bash, when called as sh, also implements the Bourne shell as well (but badly, because it leaks bash-isms), but when bash is called as bash it is a super-set of Bourne.
* https://en.wikipedia.org/wiki/Almquist_shell#dash
* https://en.wikipedia.org/wiki/Bourne_shell
* https://en.wikipedia.org/wiki/Comparison_of_command_shells
If you want to use super-set functionality adjust your shebang accordingly.
EDIT: I see what you are saying now. Bash is still installed by default despite it not being aliased to /bin/sh. So it's still possible to rely on bash features if you use it explicitly. For some reason I was under the impression bash had also been aliased to dash in the default installation. Thanks for the information.
There was a lot of gnashing of teeth when we upgraded to Debian 6 and people's (alleged) "/bin/sh" scripts broke. Most folks elected to simply change things to "/bin/bash".
One such corner case is in pipelines. Only the last command in a pipeline can cause the script to terminate.
Another corner case is `foo && bar`, often used as an abbreviated `if`, will not exit when `foo` fails.
It is not a significant task to just add `|| exit $?` after any command whose failure should cause an abort.