]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix AS_EXIT for FreeBSD sh.
authorEric Blake <ebb9@byu.net>
Sat, 25 Jul 2009 01:00:49 +0000 (19:00 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 25 Jul 2009 01:00:49 +0000 (19:00 -0600)
* lib/m4sugar/m4sh.m4 (AS_EXIT): Always supply an argument to the
shell function, since $? is not reliable on function entry.
(_AS_EXIT_PREPARE): Simplify to assume argument.
Reported by Ralf Wildenhues.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/m4sugar/m4sh.m4

index 19527f0465264c4db3db35ff5c5840a340a61bba..7ed46e1a0d94713a9c36cb5f60c5480b7324e790 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-24  Eric Blake  <ebb9@byu.net>
+
+       Fix AS_EXIT for FreeBSD sh.
+       * lib/m4sugar/m4sh.m4 (AS_EXIT): Always supply an argument to the
+       shell function, since $? is not reliable on function entry.
+       (_AS_EXIT_PREPARE): Simplify to assume argument.
+       Reported by Ralf Wildenhues.
+
 2009-07-23  Eric Blake  <ebb9@byu.net>
 
        Run more tests under Solaris.
index b2cabd7924cedd80bcc869a39b0d31a901ddd017..cc4c32fdc80c7e0fe7898981ec4d923fcccbc073 100644 (file)
@@ -542,6 +542,8 @@ esac])# AS_CASE
 # will not set $? to N while running the code set by "trap 0"
 # Some shells fork even for (exit N), so we use a helper function
 # to set $? prior to the exit.
+# Then there are shells that don't inherit $? correctly into the start of
+# a shell function, so we must always be given an argument.
 # Other shells don't use `$?' as default for `exit', hence just repeating
 # the exit value can only help improving portability.
 m4_defun([_AS_EXIT_PREPARE],
@@ -549,12 +551,11 @@ m4_defun([_AS_EXIT_PREPARE],
   [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
     [Set $? to STATUS, without forking.])], [  return $[]1])]dnl
 [AS_REQUIRE_SHELL_FN([as_fn_exit],
-  [AS_FUNCTION_DESCRIBE([as_fn_exit], [[[STATUS=$?]]],
+  [AS_FUNCTION_DESCRIBE([as_fn_exit], [STATUS],
     [Exit the shell with STATUS, even in a "trap 0" or "set -e" context.])],
-[  as_status=$?
-  set +e
-  as_fn_set_status ${1-$as_status}
-  exit ${1-$as_status}])])#_AS_EXIT_PREPARE
+[  set +e
+  as_fn_set_status $[1]
+  exit $[1]])])#_AS_EXIT_PREPARE
 
 
 # AS_EXIT([EXIT-CODE = $?])
@@ -563,7 +564,7 @@ m4_defun([_AS_EXIT_PREPARE],
 # within "trap 0", and without interference from "set -e".  If
 # EXIT-CODE is omitted, then use $?.
 m4_defun([AS_EXIT],
-[AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit[]m4_ifval([$1], [ $1])])
+[AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit m4_ifval([$1], [$1], [$][?])])
 
 
 # AS_FOR(MACRO, SHELL-VAR, [LIST = "$@"], [BODY = :])