FYI: This works in 4.3.42 (echos "ATT: execute trap function" in both).

Dr. Werner Fink wrote
The trap EXIT not allways executed, see example script

Repeat-By:
Example script
----------------------------------------------------------------
#!/bin/bash
bash -c '
_rm () { echo ATT: Execute trap function; }
trap _rm EXIT
rm -f doesnotexist
'
echo $?

bash -c '
_rm () { echo  ATT: Execute trap function; }
rm -f doesnotexist
trap _rm EXIT
'
echo $?
----------------------------------------------------------------

which results in

----------------------------------------------------------------
0
ATT: Execute trap function
0
----------------------------------------------------------------

Reply via email to