]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Work around DJGPP shell function return bug with command substitutions.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 13 Sep 2009 19:18:37 +0000 (21:18 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 15 Sep 2009 04:16:10 +0000 (06:16 +0200)
DJGPP bash 2.04 has a bug in that `return $ac_retval' done in a
shell function which also contains a command substitution causes
the shell to barf.  For more details and a fix see:
<http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2009/09/09/03:35:08>
Possible workaround include putting the `return' in a subshell
or calling another function to set the status.

* lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY)
(_AC_COMPILE_IFELSE_BODY, _AC_LINK_IFELSE_BODY)
(_AC_RUN_IFELSE_BODY, _AC_COMPUTE_INT_BODY): Use AS_SET_STATUS
instead of `return'.
* doc/autoconf.texi (Common Shell Constructs, Shell Functions):
Document the issue.
* THANKS: Update.
Report by Rugxulo and Reuben Thomas.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
THANKS
doc/autoconf.texi
lib/autoconf/general.m4

index 9e9c3755a3ca2dad62debc8fc403e8fb8d38343d..f7975434c56d3ac5f7b51315b981b6cb15a1902b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2009-09-15  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Work around DJGPP shell function return bug with command substitutions.
+       DJGPP bash 2.04 has a bug in that `return $ac_retval' done in a
+       shell function which also contains a command substitution causes
+       the shell to barf.  For more details and a fix see:
+       <http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2009/09/09/03:35:08>
+       Possible workaround include putting the `return' in a subshell
+       or calling another function to set the status.
+       * lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY)
+       (_AC_COMPILE_IFELSE_BODY, _AC_LINK_IFELSE_BODY)
+       (_AC_RUN_IFELSE_BODY, _AC_COMPUTE_INT_BODY): Use AS_SET_STATUS
+       instead of `return'.
+       * doc/autoconf.texi (Common Shell Constructs, Shell Functions):
+       Document the issue.
+       * THANKS: Update.
+       Report by Rugxulo and Reuben Thomas.
+
        DJGPP fix: Do not redirect standard input in configure scripts.
        * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): If $DJGPP is
        nonempty, do not dup fd 0 to AS_ORIGINAL_STDIN_FD, do not close
diff --git a/THANKS b/THANKS
index 28312f76a9f3bd392ead7f5b64fa93c181212fc7..ba239ca6de2d2bfd3406c8d99a6b001146b29cc0 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -319,6 +319,7 @@ Rolf Ebert                  rolf.ebert.gcc@gmx.de
 Rolf Vandevaart             Rolf.Vandevaart@sun.com
 Romain Lenglet              romain.lenglet@laposte.net
 Ruediger Kuhlmann           info@ruediger-kuhlmann.de
+Rugxulo                     rugxulo@gmail.com
 Ruslan Babayev              ruslan@babayev.com
 Russ Allbery                rra@stanford.edu
 Russ Boylan                 ross@biostat.ucsf.edu
index 72ebde0e1ef18c6cc033c6a5dcdea1ef7119e0f2..a38db005bbbec643e678213105ea49d5225a7dd9 100644 (file)
@@ -12691,7 +12691,9 @@ Also see the @code{AC_PROG_MKDIR_P} macro (@pxref{Particular Programs}).
 Emit shell code to set the value of @samp{$?} to @var{status}, as
 efficiently as possible.  However, this is not guaranteed to abort a
 shell running with @code{set -e} (@pxref{set, , Limitations of Shell
-Builtins}).
+Builtins}).  This should also be used at the end of a complex shell
+function instead of @samp{return} (@pxref{Shell Functions}) to avoid
+a @acronym{DJGPP} shell bug.
 @end defmac
 
 @defmac AS_TR_CPP (@var{expression})
@@ -15502,6 +15504,12 @@ $ @kbd{ash -c 'foo()@{ echo $?; @}; trap foo 0; (exit 2); exit 2'; echo $?}
 2
 @end example
 
+@acronym{DJGPP} bash 2.04 has a bug in that @command{return} from a
+shell function which also used a command substitution causes a
+segmentation fault.  To work around the issue, you can use
+@command{return} from a subshell, or @samp{AS_SET_STATUS} as last command
+in the execution flow of the function (@pxref{Common Shell Constructs}).
+
 Not all shells treat shell functions as simple commands impacted by
 @samp{set -e}, for example with Solaris 10 @command{bin/sh}:
 
index b850c8a9c18c7e2c40a1c31d4a10d59090ed94f8..c11908888d45393e140e52ac4cf61a3d43721dec 100644 (file)
@@ -2457,7 +2457,7 @@ m4_define([_AC_PREPROC_IFELSE_BODY],
     [_AC_MSG_LOG_CONFTEST
     ac_retval=1])
   AS_LINENO_POP
-  return $ac_retval
+  AS_SET_STATUS([$ac_retval])
 ])# _AC_PREPROC_IFELSE_BODY
 
 
@@ -2546,7 +2546,7 @@ m4_define([_AC_COMPILE_IFELSE_BODY],
       [_AC_MSG_LOG_CONFTEST
        ac_retval=1])
   AS_LINENO_POP
-  return $ac_retval
+  AS_SET_STATUS([$ac_retval])
 ])# _AC_COMPILE_IFELSE_BODY
 
 
@@ -2610,7 +2610,7 @@ m4_define([_AC_LINK_IFELSE_BODY],
   # left behind by Apple's compiler.  We do this before executing the actions.
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
   AS_LINENO_POP
-  return $ac_retval
+  AS_SET_STATUS([$ac_retval])
 ])# _AC_LINK_IFELSE_BODY
 
 
@@ -2682,7 +2682,7 @@ m4_define([_AC_RUN_IFELSE_BODY],
        ac_retval=$ac_status])
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
   AS_LINENO_POP
-  return $ac_retval
+  AS_SET_STATUS([$ac_retval])
 ])# _AC_RUN_IFELSE_BODY
 
 
@@ -3004,7 +3004,7 @@ m4_define([_AC_COMPUTE_INT_BODY],
                        [ac_retval=0], [ac_retval=1])
   fi
   AS_LINENO_POP
-  return $ac_retval
+  AS_SET_STATUS([$ac_retval])
 ])# _AC_COMPUTE_INT_BODY
 
 # AC_COMPUTE_INT(VARIABLE, EXPRESSION, PROLOGUE, [IF-FAILS])