2006-01-23 23:17:06 +00:00
|
|
|
\section trap trap - perform an action when the shell receives a signal
|
2005-12-17 21:30:52 +00:00
|
|
|
|
|
|
|
\subsection trap-synopsis Synopsis
|
2014-08-01 12:25:41 +00:00
|
|
|
\fish{synopsis}
|
2014-08-01 02:37:32 +00:00
|
|
|
trap [OPTIONS] [[ARG] SIGSPEC ... ]
|
|
|
|
\endfish
|
2005-12-17 21:30:52 +00:00
|
|
|
|
|
|
|
\subsection trap-description Description
|
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
`trap` is a wrapper around the fish event delivery
|
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 07:56:01 +00:00
|
|
|
framework. It exists for backwards compatibility with POSIX
|
|
|
|
shells. For other uses, it is recommended to define an <a
|
2005-12-17 21:30:52 +00: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 07:56:01 +00:00
|
|
|
The following parameters are available:
|
2005-12-17 21:30:52 +00:00
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
- `ARG` is the command to be executed on signal delivery.
|
|
|
|
- `SIGSPEC` is the name of the signal to trap.
|
|
|
|
- `-h` or `--help` displays help and exits.
|
|
|
|
- `-l` or `--list-signals` prints a list of signal names.
|
|
|
|
- `-p` or `--print` prints all defined signal handlers.
|
2005-12-17 21:30:52 +00:00
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
If `ARG` and `SIGSPEC` are both specified, `ARG` is the command to be
|
|
|
|
executed when the signal specified by `SIGSPEC` is delivered.
|
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 07:56:01 +00:00
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
If `ARG` is absent (and there is a single SIGSPEC) or -, each specified
|
2005-12-17 21:30:52 +00:00
|
|
|
signal is reset to its original disposition (the value it had upon
|
2014-08-01 02:37:32 +00:00
|
|
|
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
|
2005-12-17 21:30:52 +00:00
|
|
|
it invokes.
|
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
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
|
2005-12-17 21:30:52 +00:00
|
|
|
associated with each signal.
|
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
Signal names are case insensitive and the `SIG` prefix is optional.
|
2005-12-17 21:30:52 +00:00
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
The return status is 1 if any `SIGSPEC` is invalid; otherwise trap
|
2005-12-17 21:30:52 +00: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 07:56:01 +00:00
|
|
|
|
|
|
|
\subsection trap-example Example
|
|
|
|
|
2014-08-01 02:37:32 +00:00
|
|
|
`trap "status --print-stack-trace" SIGUSR1` prints a stack trace
|
|
|
|
each time the `SIGUSR1` signal is sent to the shell.
|