trap [ arg ] [ sig ... ]
       arg is a series of commands (usually quoted to pro-
       immediate  evaluation by the shell) to be read  and
       the  shell receives any of the signals specified by
       sig  args.  Each sig can be given as a  number,  or
       a  signal  either with or without the string SIG in
       HUP, and SIGHUP are all the same signal).

       If  arg  is  `-',  then the specified  signals  are
       defaults, or, if no sig args are present, all traps

       If arg is an  empty  string,  then  the   specified
       ignored  by  the  shell (and by the commands it in-

       If  arg  is  omitted but one or more sig  args  are
       the  first  argument  is  a  valid signal number or
       is the same as if arg had been specified as `-'.

       The  trap  command  with   no  arguments  prints  a
       associated with each signal.

       If sig is ZERR then arg will be executed after each
       a nonzero exit status.  ERR is an alias for ZERR on
       have no SIGERR signal (this is the usual case).

       If  sig  is  DEBUG then arg will be executed before
       the  option  DEBUG BEFORE CMD is set (as it  is  by
       after  each  command.  Here, a `command' is what is
       `sublist'  in the shell grammar,  see  the  section
       &  PIPELINES in zshmisc(1).  If DEBUG BEFORE CMD is
       additional  features  are  available.    First,  it
       skip  the  next  command by setting the option  ERR
       description  of  the  ERR  EXIT  option  in  zshop-
       shell  parameter ZSH DEBUG CMD is set to the string
       to  the  command  to   be  executed  following  the
       this  string  is  reconstructed  from  the internal
       not be formatted the same way as the original text.
       ter is unset after the trap is executed.

       If sig is 0 or EXIT and the trap statement  is  ex-
       the  body  of a function, then the command  arg  is
       the  function  completes.   The  value of $? at the
       tion is the exit status of the shell or the  return
       function exiting.  If sig is 0 or EXIT and the trap
       not executed inside the body of  a  function,  then
       is  executed  when  the  shell terminates; the trap
       zshexit hook functions.

       ZERR, DEBUG, and EXIT traps are not executed inside
       ZERR  and DEBUG traps are  kept  within  subshells,
       traps are reset.

       Note  that traps defined with the trap builtin  are
       ferent  from those defined as `TRAPNAL () { ... }',
       have  their  own function  environment  (line  num-
       ables,  etc.)  while the former use the environment
       in which they were called.  For example,

              trap 'print $LINENO' DEBUG

       will  print  the  line number of a command executed
       run, while

              TRAPDEBUG() { print $LINENO; }

       will always print the number zero.

       Alternative signal names are allowed  as  described
       above.   Defining a trap under either  name  causes
       an alternative name to be removed.  However, it  is
       that  for  consistency  users   stick   exclusively
       another.
