Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 4.3.11 TRAPEXIT() on cygwin
On 11 January 2011 04:25, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> When a subshell is entered, traps that are not being ignored shall
>> be set to the default actions, except in the case of a command
>> substitution containing only a single trap command, when the traps
>> need not be altered.
>
> Ah, the manpage says this
> ( list )
> Execute list in a subshell. Traps set by the trap
> builtin are reset
> to their default values while executing list.
>
> and it is true:
> % trap 'echo hello >&2' EXIT
> % a=$(ls)
> % TRAPEXIT() { echo function hello >&2 }
> % a=$(ls)
> function hello
One might take issue with this statement in the manpage though,
The functions beginning `TRAP' may alternatively be defined with the trap
builtin: this may be preferable for some uses, as they are then run in the
environment of the calling process, rather than in their own function envi‐
ronment. Apart from the difference in calling procedure and the fact that
the function form appears in lists of functions, the forms
TRAPNAL() {
# code
}
and
trap '
# code
' NAL
are equivalent.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author