[Top][All Lists]

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

Re: bash 3.2.51, ERR traps and subshells

From: Andres P
Subject: Re: bash 3.2.51, ERR traps and subshells
Date: Tue, 22 Jun 2010 14:40:22 -0430

On Tue, Jun 22, 2010 at 2:21 PM, Chet Ramey <address@hidden> wrote:
> On 6/22/10 12:51 AM, Andres P wrote:
>> Bash 4.1 does not set the ERR trap:
> It does, but remember that the ERR trap is only executed under the
> circumstances that would cause the shell to exit when set -e is enabled.

To clarify, I meant that it does not trigger the trap, not that the
actual `trap "<eval>" ERR' did not work.

> One of the changes between bash-3.2 and bash-4.0 was to make command
> substitution understand when it was being executed in a context where
> the return value would be ignored, and to ignore any inherited setting
> of -e and the ERR trap in those cases.  This was part of the big change
> in the behavior of set -e in response to the consensus of the Posix
> working group, and more directly the result of a bug report.
>> The ERR trap is not executed if the failed command is part of the command
>> list immediately  following  a while  or until keyword, part of the test in 
>> an
>> if statement, part of a && or ⎪⎪ list, or if the command's return value is
>> being inverted via !
> The exit status of the command substitution will ultimately be ignored
> because it's part of an assignment statement on the LHS of a || list, so
> the commands run in the command substitution inherit that state.
> Chet

Thanks, this behaviour seemed strange to me.

Although eventually the outer `||' list taking precedence over contained
subshells will seem natural in my use cases. It's more consistent.

Andres P

reply via email to

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