I have a very simple question. I can't believe the Bash manpage doesn't explain this already, but anyway...If I issue the trap builtin twice [for the same signal], what happens? Is the second command added to the first, or does it replace the first?trap Foo SIGINT...trap Bar SIGINT...When SIGINT happens, does Bash just run Bar, or does it run Foo as well? Or something else...?
Bash: issuing trap twice
bash;shell;trap
The command is replaced.The manpage states: trap [-lp] [[arg] sigspec ...]        The  command  arg  is  to  be  read  and executed when the shell        receives signal(s) sigspec.  If arg is absent (and  there  is  a        single  sigspec)  or  -,  each  specified signal is reset to its        original disposition (the value it  had  upon  entrance  to  the        shell).   If arg is the null string the signal specified by each        sigspec is ignored by the shell and by the commands it  invokes.        If  arg  is  not present and -p has been supplied, then the trap        commands associated with each  sigspec  are  displayed.   If  no        arguments  are  supplied or if only -p is given, trap prints the        list of commands associated with each  signal.   The  -l  option        causes  the shell to print a list of signal names and their cor        responding numbers.   Each  sigspec  is  either  a  signal  name        defined  in  <signal.h>,  or  a signal number.  Signal names are        case insensitive and the SIG prefix is optional.It states the command arg is to be read and executed ... period. It would otherwise not be possible to reset the signal handling if the arg was always added to the list.