> Stefano Lattarini a écrit :
> > I thought that when bash detect a syntax errors in a script,
> > it would pass a $? != 0 to the code in the exit trap, regardless
> > of whether `set -e' is active or not.
> >
> > [CUT]
> >
> > I think this can be classified as a bug in bash (in some
> > situations, a very nasty one). Please let me know if I
> > have misunderstood something, or if there is a simple
> > workaround.
>
> I am not familiar with the standard(s), but... isn't having
> expectations in the case of syntax errors a bit far-fetched?
>
Well, I'd not expect that the exit trap is executed flawlessly,
and not even that it is executed at all, but at least the shell
should abort the script and exit with a non-zero status.  This
is a much more rational approach than having the flawed script
exiting sucessfully, IMHO.

In fact, I've been bitten by this "bug" (or limitation) when a
stupid syntax error leaked in some scripts part of a testsuite
(that was my fault).  The scripts erroneously apperead as PASS'd,
while they should have been marked as FAIL'd -- a vary bad thing
in my opinion.  And I discovered the bug only when I tried to run
the testsuite with dash, to check its "portability".

Aside that, the exit trap executes correctly even on bash when
`set -e' is not active, which makes the described behaviour
seeming more a bug rather than a limitation.

By the way, sorry for the duplicate message.

Regards,
     Stefano


Reply via email to