My mistake, the 'trap' of (5) needs to be defined within single quotes to prevent the $? from expanding too soon:
$ trap 'echo Exit $?' ERR Freddy Vulto
My mistake, the 'trap' of (5) needs to be defined within single quotes to prevent the $? from expanding too soon:
$ trap 'echo Exit $?' ERR Freddy Vulto