trap: Handling command lists

The command list is placed between single quotes, as the command line is scanned twice, once when the shell first encounters the trap command and again when it is being executed.

   trap 'command-list' signal-list

The single quotes inhibit immediate command and variable substitution but are stripped off after the first scan, so that the commands are processed when the command is actually executed.

If command-list is not specified, then the action taken on receipt of any signal in the signal-list is reset to the default system action.

If command-list is an explicitly quoted null command (' ' or " "), then the signals in signal-list are ignored by the shell.

The command-list is treated like a subroutine call. The commands in the list are executed when the signal is trapped and control is then returned to the place at which it was interrupted.


[Home] [Search] [Index] This site maintained by webmaster@softlab.ece.ntua.gr