Wait ...
* Eric Blake wrote on Tue, Nov 18, 2008 at 06:03:51PM CET:
> +Portable scripts should not use @samp{set -e} if @command{trap} is used
> +to install an exit handler. This is because Tru64/OSF 5.1 @command{sh}
> +enters the trap handler with the exit status of the command prior to the
> +one that triggered the errexit handler:
> +
> [EMAIL PROTECTED]
> +$ @kbd{bash -c 'trap '\''echo $?'\'' 0; set -e; false'}
> +1
> +$ @kbd{sh -c 'trap '\''echo $?'\'' 0; set -e; false'}
> +0
This isn't correct. Even Tru64 sh will echo 1 in this case.
Hmm. This exposes it:
$ sh -ec 'trap '\''echo $?'\'' 0; false;'
0
But at the same time:
$ sh -c 'set -e; trap '\''echo $?'\'' 0; false;'
1
Weird.
> +
> [EMAIL PROTECTED]
> +Thus, when writing a script in M4sh, rather than trying to rely on
> [EMAIL PROTECTED] -e}, it is better to append @samp{|| AS_EXIT([$?])} to any
> +statement where it is desirable to abort on failure.
Cheers,
Ralf