On 3/31/10 1:45 AM, Siddhesh Poyarekar wrote:

> Bash Version: 4.1
> Patch Level: 2
> Release Status: release
> 
> Description:
>               When output of trap is piped to another command, say, less or
>               cat -, it shows only ignored signals.

As the standard is currently written, this is the correct behavior.

The standard considers traps in subshells in two places: where it talks
about "subshell environments" and where it describes the behavior of trap.

The former says only that all commands in a pipeline are run in a subshell
environment, and that in a subshell environment traps "are set to the
default values."  The latter says that "when a subshell is entered, traps
that are not being ignored are set to the default actions."  This is an
obvious contradiction, and most shells implement the latter.

Bash and some other shells special-case command substitution, because the
standard includes an example illustrating the use of command substitution
to save and restore traps.  This is not univeral -- dash, for instance,
does not do it.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/


Reply via email to