[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bash 4, subshells and ERR
From: |
Ian Fitchet |
Subject: |
bash 4, subshells and ERR |
Date: |
Wed, 08 Dec 2010 15:48:15 -0000 |
User-agent: |
G2/1.0 |
Hi,
ERR is notionally triggered when a simple command fails. Subshells
are both compound commands and do not inherit ERR. This is what I
expect (read: am used to):
3.2.0% trap 'echo SIGERR' ERR
3.2.0% ( false; )
3.2.0%
However, now I see:
4.1.0% trap 'echo SIGERR' ERR
4.1.0% ( false; )
SIGERR
4.1.0%
I'm not saying it's a bad thing only that it's different and not
documented.
There's also a comment in the 4.1 CHANGES regarding ((:
j. The [[ and (( commands are now subject to the setting of `set -e'
and the
ERR trap.
which made me wonder if something had changed regard compound
commands across the piece.
(( i=0 )) now triggers the ERR trap. That (( returned non-zero when
the expression evaluated to zero always struck me as a feature but as
a compound command it never triggered ERR. Now it might become
inconvenient! :-)
Cheers,
Ian
- bash 4, subshells and ERR,
Ian Fitchet <=