www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2009/09/13/15:49:24

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Date: Sun, 13 Sep 2009 22:49:22 +0300
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: [PATCH 4/4] Work around DJGPP shell function return bug with command substitutions.
In-reply-to: <20090913191837.GE29257@gmx.de>
X-012-Sender: halo1 AT inter DOT net DOT il
To: Ralf Wildenhues <Ralf DOT Wildenhues AT gmx DOT de>
Cc: djgpp-workers AT delorie DOT com
Message-id: <838wgizku5.fsf@gnu.org>
References: <20090913191226 DOT GA29257 AT gmx DOT de> <20090913191837 DOT GE29257 AT gmx DOT de>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham 
> 	version=3.1.0
> Date: Sun, 13 Sep 2009 21:18:37 +0200
> From: Ralf Wildenhues <Ralf DOT Wildenhues AT gmx DOT de>
> 
> 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 see
> <http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp/2006/08/08/16:37:27>.
> 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.
> ---
> 
> * Ralf Wildenhues wrote on Sun, Sep 13, 2009 at 09:12:28PM CEST:
> > -- Failures due to some obscure DJGPP shell bug with 'return $ac_retval'
> > worked around with patch.
> > 
> > Test failures: not recorded (several instances though)
> 
> While there is a fix for upstream for this bug now, it is prudent to
> still work around it, so users that haven't updated can work too.
> 
> Can we have a full name to put in THANKS (change omitted here)?
> 
> Thanks,
> Ralf
> 
>  THANKS                  |    1 +
>  doc/autoconf.texi       |   10 +++++++++-
>  lib/autoconf/general.m4 |   10 +++++-----
>  3 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/autoconf.texi b/doc/autoconf.texi
> index 32e6683..b1dbac3 100644
> --- a/doc/autoconf.texi
> +++ b/doc/autoconf.texi
> @@ -12692,7 +12692,9 @@ Common Shell Constructs
>  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 DJGPP shell bug.
>  @end defmac
>  
>  @defmac AS_TR_CPP (@var{expression})
> @@ -15503,6 +15505,12 @@ Shell Functions
>  2
>  @end example
>  
> +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.
> +Details are not unclear; 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}:
>  
> diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
> index fd40c43..a4271bc 100644
> --- a/lib/autoconf/general.m4
> +++ b/lib/autoconf/general.m4
> @@ -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])
> -- 
> 1.6.3.3.345.gb7132
> 
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019