-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 10/22/2008 12:25 PM: > Paolo Bonzini <bonzini <at> gnu.org> writes: > >>> (exit $ac_status); }]) >> in _AC_RUN_LOG_STDERR and _AC_RUN_LOG could also be changed to an >> ac_func_set_status shell function that does just "return $1". A >> candidate for m4sh maybe? > > Absolutely! Nice catch. I think an m4sh addition would be nice, whether or > not we end up using it in _AC_DO.
More research - zsh and pdksh optimize a lone '(exit n)', and change $? without forking a subshell. However, bash 3.2 and ash still proceed to fork. When it comes to exiting the overall script, this is only one more fork than a shell function. But within _AC_RUN_LOG_STDERR, it adds up fast. I'm thinking of borrowing from automake (but naming the function as_func_exit instead of Exit): http://lists.gnu.org/archive/html/automake-patches/2008-09/msg00009.html Even if not many forks are saved, the benefit of writing a shell function will make for smaller configure files, as AS_EXIT is expanded lots of times, and as_func_exit $var is shorter than { (exit $var); exit $var; } How likely is it that m4sh users care about 'set -e' bugs prior to exiting? Should m4sh cater to that OSF1/Tru64 sh bug? Here's what I'm thinking of implementing; does the idea look okay? # AS_SET_STATUS(VALUE) # -------------------- # Set $? to VALUE, without forking. m4_define([AS_SET_STATUS], [AS_REQUIRE([_AS_EXIT_PREPARE])dnl as_func_set_status $1]) m4_defun([AS_EXIT], [AS_REQUIRE([_AS_EXIT_PREPARE])dnl as_func_exit m4_default([$1], [1])]) m4_defun([_AS_EXIT_PREPARE], [as_func_set_status () { return $[]1 } as_func_exit () { set +e as_func_set_status $[]1 exit $[]1 } ]) - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkj/+cwACgkQ84KuGfSFAYA54gCgxKr0I1nP/0p4uVXiJpEHsmPS 75cAn2+9KSZ7gPvnZg/2kDaT/K2QXI33 =ZHvE -----END PGP SIGNATURE-----
