Re: [v2 PATCH] eval: Only restore exit status on exit/return

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

 



On Sat, Dec 08, 2018 at 03:45:11PM +0000, Harald van Dijk wrote:
>
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -116,10 +116,7 @@ INCLUDE "eval.h"
>  EXITRESET {
>  	evalskip = 0;
>  	loopnest = 0;
> -	if (savestatus >= 0) {
> -		exitstatus = savestatus;
> -		savestatus = -1;
> -	}
> +	savestatus = -1;
>  }
>  #endif

The reason this is needed is to support a naked return.  With
your patch a naked return would either have to always return the
saved status or the new status.  Neither of which is what we
want.

Please refer to

commit 70c16dd30d4cf824aa895e9f6c095fec741c65a8
Author: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date:   Mon Oct 6 21:51:26 2014 +0800

    [BUILTIN] Return without arguments in a trap should use status outside traps

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux