Bash – ny way to determine the signal that was caught from inside a bash trap function

bashsignals

I have a bash script, in which I have specified via trap that a function will be called for any (catchable) signal.

typeset -i sig=1
while (( sig < 65 )); do
    trap myfunc $sig
    let sig=sig+1
done

Is there any way my script can determine which signal has been caught?

Best Answer

trap "signum=${sig};myfunc" "$sig"
Related Question