Script test.sh :
set -euo pipefail function _trap_ext { echo '_trap_ext' } function _trap_error { echo '_trap_error' } trap "_trap_ext" EXIT trap "_trap_error" ERR readonly foo='bar' foo='bar' echo 'foobar'
Output:
./test.sh: line 14: foo: readonly variable _trap_ext
The script terminates at line 14 due to an error ( -e ), but the _trap_error function _trap_error not called. Why not?
GNU bash, version 4.1.2 (1) -release (x86_64-unknown-linux-gnu), 4.2.45 (1) -release (i586-suse-linux-gnu)
source share