Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer -flto=auto -ffat-lto-objects
-fstack-protector-strong -fstack-clash-protection -Wformat
-Werror=format-security -fcf-protection -Wall
uname output: Linux VMX-T16-7661 6.8.0-86-generic #87-Ubuntu SMP
PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 21
Release Status: release
Description:
The man-page says under set -e: "...A trap on ERR, if set, is executed
before the shell exits. ..."
If such a handler sets "set +e", the original flow is resumed after the
handler exits.
I would expect that once the exit due to "set -e" is initiated, it
should not be cancelable.
The example script in Repeat-By produces the following output:
main: the next command will fail
handler: the next command will fail
handler: after failing command
main: after failing command
Expected output:
main: the next command will fail
handler: the next command will fail
handler: after failing command
Repeat-By:
----------------- snip -----------------
handler () {
set +e
echo "handler: the next command will fail"
false
echo "handler: after failing command"
}
trap handler ERR
set -e
echo "main: the next command will fail"
false
echo "main: after failing command"
----------------- snip -----------------