Re: 'set -e' and 'trap 0' togheter does not work as expected on syntax errors

2009-08-22 Thread Stefano Lattarini
At Saturday 22 August 2009, Chet Ramey wrote: > Stefano Lattarini wrote: >> I have the following scripts: >> >> [CUT] >> >> I thought that when bash detect a syntax errors in the script, >> it would pass a $? != 0 to the code in the exit trap, regardless >> of whether `set -e' is active or not. >

Re: 'set -e' and 'trap 0' togheter does not work as expected on syntax errors

2009-08-21 Thread Chet Ramey
Stefano Lattarini wrote: > I have the following scripts: > > $ cat nobug.sh > trap 'e=$?; [ $e -gt 0 ] && echo "OK" || echo "BAD"; exit $e' 0 > # syntax error here > && true > > $ cat bug.sh > set -e > trap 'e=$?; [ $e -gt 0 ] && echo "OK" || echo "BAD"; exit $e' 0 > # syntax error here

'set -e' and 'trap 0' togheter does not work as expected on syntax errors

2009-08-21 Thread Stefano Lattarini
I have the following scripts: $ cat nobug.sh trap 'e=$?; [ $e -gt 0 ] && echo "OK" || echo "BAD"; exit $e' 0 # syntax error here && true $ cat bug.sh set -e trap 'e=$?; [ $e -gt 0 ] && echo "OK" || echo "BAD"; exit $e' 0 # syntax error here && true I thought that when bash detect a syn