trap ... ERR, how to get the signal code?
Inspired by https://software.codidact.com/posts/294883 , I had a look at shell scripting (bash).
I have little experience there as I prefer (long) one-liners.
For trap there is some kind of wildcard, ERR.
How to get the actual signal code?
1 answer
ERR is not a signal, so there is no signal code to get. From man bash:
If a sigspec is ERR, the command arg is executed whenever a pipeline (which may consist of a single simple command), a list, or a compound command returns a non-zero exit status, subject to the following conditions. The ERR trap is not executed if the failed command is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of a command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted using !. These are the same conditions obeyed by the errexit (-e) option.

0 comment threads