2006-01-24 07:17:06 +08:00
|
|
|
\section trap trap - perform an action when the shell receives a signal
|
2005-12-18 05:30:52 +08:00
|
|
|
|
|
|
|
\subsection trap-synopsis Synopsis
|
|
|
|
<tt>trap [OPTIONS] [[ARG] SIGSPEC ... ]</tt>
|
|
|
|
|
|
|
|
\subsection trap-description Description
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
\c trap is a wrapper around the fish event delivery
|
|
|
|
framework. It exists for backwards compatibility with POSIX
|
|
|
|
shells. For other uses, it is recommended to define an <a
|
2005-12-18 05:30:52 +08:00
|
|
|
href='index.html#event'>event handler</a>.
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
The following parameters are available:
|
2005-12-18 05:30:52 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
- \c ARG is the command to be executed on signal delivery.
|
|
|
|
- \c SIGSPEC is the name of the signal to trap.
|
|
|
|
- \c -h or \c --help displays help and exits.
|
|
|
|
- \c -l or \c --list-signals prints a list of signal names.
|
|
|
|
- \c -p or \c --print prints all defined signal handlers.
|
2005-12-18 05:30:52 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
If \c ARG and \c SIGSPEC are both specified, \c ARG is the command to be
|
|
|
|
executed when the signal specified by \c SIGSPEC is delivered.
|
|
|
|
|
|
|
|
If \c ARG is absent (and there is a single SIGSPEC) or -, each specified
|
2005-12-18 05:30:52 +08:00
|
|
|
signal is reset to its original disposition (the value it had upon
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
entrance to the shell). If \c ARG is the null string the signal
|
|
|
|
specified by each \c SIGSPEC is ignored by the shell and by the commands
|
2005-12-18 05:30:52 +08:00
|
|
|
it invokes.
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
If \c ARG is not present and \c -p has been supplied, then the trap commands
|
|
|
|
associated with each \c SIGSPEC are displayed. If no arguments are
|
|
|
|
supplied or if only \c -p is given, \c trap prints the list of commands
|
2005-12-18 05:30:52 +08:00
|
|
|
associated with each signal.
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
Signal names are case insensitive and the \c SIG prefix is optional.
|
2005-12-18 05:30:52 +08:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
The return status is 1 if any \c SIGSPEC is invalid; otherwise trap
|
2005-12-18 05:30:52 +08:00
|
|
|
returns 0.
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 15:56:01 +08:00
|
|
|
|
|
|
|
\subsection trap-example Example
|
|
|
|
|
|
|
|
<code>trap "status --print-stack-trace" SIGUSR1</code> prints a stack trace
|
|
|
|
each time the \c SIGUSR1 signal is sent to the shell.
|