triggering of ERR trap differs between bash 3.2.39 & 4.0.28

2009-11-08 Thread Amit Dor-Shifer
I've the following script: set -eE on_error() { echo ERROR ERROR; } trap on_error ERR if [ -n "$(echo $1 |grep a)" ];then echo "input contains 'a'" fi When executed under bash-4, on_error is evaluated as part of the expression in the 'if'. This does not happen in 3.2: amit0 ~ # bash --ve

Re: triggering of ERR trap differs between bash 3.2.39 & 4.0.28

2009-11-08 Thread Amit Dor-Shifer
f shell when -e option is in effect to reflect consensus of Posix shell standardization working group. Thanks, Amit Chet Ramey wrote: Amit Dor-Shifer wrote: cm.stargate ~ # bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap on_error ERR;if [ -n "$(echo $0 |grep a)"

Re: triggering of ERR trap differs between bash 3.2.39 & 4.0.28

2009-11-09 Thread Amit Dor-Shifer
Seems like I've erroneously switched between bash versions exhibiting the difference. It's 3.2.39 that evaluates 'on_error' when catching the trap. From the start: # bash-4.0_p28/image/bin/bash --version GNU bash, version 4.0.28(2)-release (x86_64-pc-linux-gnu) Copyright (C) 2009 Free Software