Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Chet Ramey
On 6/22/10 3:10 PM, Andres P wrote: >> 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. >> > > Thanks, this behaviour seemed strang

Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Andres P
On Tue, Jun 22, 2010 at 2:21 PM, Chet Ramey 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

Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Chet Ramey
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. > > $ env -i HOME="$HOME" TERM="$TERM" bash3 <<\! > > set -o errexit > set -o

Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Stefano Lattarini
At Tuesday 22 June 2010, Andres P wrote: > On Tue, Jun 22, 2010 at 4:45 AM, Stefano Lattarini > > wrote: > >> ++ false # Subshell false > >> +++ TRIGGERED_ERR # Ignores outer "|| true" > > > > No, it doesen't even see it; the script seen by the subshell > > consists just of the string

Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Andres P
On Tue, Jun 22, 2010 at 4:45 AM, Stefano Lattarini wrote: >> ++ false           # Subshell false >> +++ TRIGGERED_ERR  # Ignores outer "|| true" > No, it doesen't even see it; the script seen by the subshell consists > just of the string "false", so there is no `||' the subshell can see. > And thi

Re: bash 3.2.51, ERR traps and subshells

2010-06-22 Thread Stefano Lattarini
At Tuesday 22 June 2010, Andres P wrote: > Bash 4.1 does not set the ERR trap: > > $ env -i HOME="$HOME" TERM="$TERM" bash3 <<\! > > set -o errexit > set -o errtrace > > TRIGGERED_ERR() { return $?; } > > trap 'TRIGGERED_ERR' ERR > > set -o xtrace > > var=$(false) || true Here, the subs

bash 3.2.51, ERR traps and subshells

2010-06-21 Thread Andres P
Bash 4.1 does not set the ERR trap: $ env -i HOME="$HOME" TERM="$TERM" bash3 <<\! set -o errexit set -o errtrace TRIGGERED_ERR() { return $?; } trap 'TRIGGERED_ERR' ERR set -o xtrace var=$(false) || true echo $? var=$(false || true) # only way of not triggering it... echo $? ! ++