bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trap output piped to another program gives incomplete results


From: Chet Ramey
Subject: Re: trap output piped to another program gives incomplete results
Date: Fri, 09 Apr 2010 23:21:40 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]