bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS_EXIT and default value


From: Eric Blake
Subject: Re: AS_EXIT and default value
Date: Fri, 24 Jul 2009 19:02:50 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 7/24/2009 2:39 PM:
> Do you see any other way out except to undo the move to use a shell
> function for AS_EXIT (740062eb42)?

Yep - by always passing an argument to the function (that is, doing the
defaulting in m4sugar rather than in shell), as follows:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----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

iEYEARECAAYFAkpqWboACgkQ84KuGfSFAYClTgCghYxAtiXsSpIeFWe2kaUIAK2x
EiEAn3b8+uw+KZe0qsMzb6eNGAllyap+
=SVGp
-----END PGP SIGNATURE-----
>From 3171783adb625c3d6bae7870d6b6c5abbc933f87 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 24 Jul 2009 19:00:49 -0600
Subject: [PATCH] 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.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |    8 ++++++++
 lib/m4sugar/m4sh.m4 |   13 +++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 19527f0..7ed46e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-24  Eric Blake  <address@hidden>
+
+       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  <address@hidden>

        Run more tests under Solaris.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index b2cabd7..cc4c32f 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -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 = :])
-- 
1.6.3.3.334.g916e1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]