mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-07 17:17:44 +03:00
abfa9a0e7d
Unfortunately, when checking the return/exit code using &&, ||, if, while, etc., `set -e` is disabled for all nested functions as well, which leads to incorrectly ignored errors, *sigh*. Example: ``` set -eu set -o pipefail task() { echo "task init" echo "this should fail" false nonexistentcommand echo "task end (we shouldn't be here)" } if ! task; then echo >&2 "The task failed" exit 1 else echo "The task passed" fi ``` ``` $ bash test.sh task init this should fail test.sh: line 10: nonexistentcommand: command not found task end (we shouldn't be here) The task passed $ echo $? 0 ``` But without the `if`, everything works "as expected": ``` set -eu set -o pipefail task() { echo "task init" echo "this should fail" false nonexistentcommand echo "task end (we shouldn't be here)" } task ``` ``` $ bash test.sh task init this should fail $ echo $? 1 ``` Wonderful. |
||
---|---|---|
.. | ||
Makefile | ||
test.sh |