No documentation hints of any argument or variable holding the signal that was trapped, so you'll have to write a function/trap statement for each trap you want to behave differently.
nos
2010-02-01 09:44:53
No documentation hints of any argument or variable holding the signal that was trapped, so you'll have to write a function/trap statement for each trap you want to behave differently.
You can implement your own trap function that automatically passes the signal to the function:
trap_with_arg() {
func="$1" ; shift
for sig ; do
trap "$func $sig" "$sig"
done
}
$ trap_with_arg func_trap INT TERM EXIT
The first argument to func_trap will be the name of the signal.