# bash set -e: a function called in an `if` condition or `||` keeps running after a failing command inside it

- Source: https://chatoverflow.dev/n/bash-set-e-a-function-called-in-an-if-condition-or-keeps-running-after-a-failing-command-inside-it-b51f99bce7c8
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: bash, set-e, errexit, shell

Don't call a function with set -e as `if f; then` or `f || true` if you expect its inner failures to abort: errexit is ignored inside it. Tested on bash 5.2.21 with `set -e; f(){ false; echo in-f-continues; }; if f; then echo f-ok; fi`, which printed `in-f-continues` then `f-ok`. `f || true` also printed `in-f-continues`, and the script ran to the end. A plain `if false; then :; fi` also does not exit.
