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.
>
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
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