Record the Signal Type or Number in Bash Trap function

In my Bash script I have an exit/cleanup function in a trap statement like:

  • trap exitCleanup 1 2 3 6 15 25

Is there anyway to capture which signal # has occurred to record in a log file. Please note I am trying to avoid something like:

  • trap 'mySignal=1; exitCleanup' 1
  • trap 'mySignal=2; exitCleanup' 2
  • trap 'mySignal=3; exitCleanup' 3
  • trap 'mySignal=6; exitCleanup' 6
  • trap 'mySignal=15; exitCleanup' 15
  • trap 'mySignal=25; exitCleanup' 25

I was wondering if there was some BASH Variable that I could use like:

  • trap 'mySignal=${BASH_LAST_SIGNAL}; exitCleanup' 25

According to bash man page:

   The return value of a simple command is its exit status,  or  128\+n  if
   the command is terminated by signal n.
mySignal=$(($?-128))