Is it possible to use history expansion within a trap [commands] ERR
?
I've tried manually enabling history expansion within the environment and within the trap commands argument (trap 'set -H; echo !-2 failed' ERR
) but could not get it to work as the shell always ended up just interpreting "!-2" literally.
Every designator I've tried from Bash's manual ended up being interpreted literally once the trap got activated but they work just fine when called somewhere else in the same environment.