Is it necessary to specify traps other than EXIT?
问题 I see a lot of shell scripts that do: trap cmd 0 1 2 3 13 15 # EXIT HUP INT QUIT PIPE TERM In every shell I have access to at the moment, all the traps other than 0 are redundant, and cmd will be executed upon receipt of a signal if the trap is simply specified: trap cmd 0 Is the latter specification sufficient, or do some shells require the other signals to be specified? 回答1: I think trap 0 is executed just prior to script termination in all cases, so is useful for cleanup functionality