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

2018-12-14 Thread Harald van Dijk
On 14/12/2018 10:07, Harald van Dijk wrote: On 14/12/2018 09:47, Herbert Xu wrote: On Fri, Dec 14, 2018 at 09:37:09AM +, Harald van Dijk wrote: Still, that works as well, doesn't it? The control flow is basically the same so the logic in my other message applies. returncmd() doesn't use

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

2018-12-14 Thread Harald van Dijk
On 14/12/2018 09:47, Herbert Xu wrote: On Fri, Dec 14, 2018 at 09:37:09AM +, Harald van Dijk wrote: Still, that works as well, doesn't it? The control flow is basically the same so the logic in my other message applies. returncmd() doesn't use exceptions, so you get to dotrap() which

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

2018-12-14 Thread Herbert Xu
On Fri, Dec 14, 2018 at 09:37:09AM +, Harald van Dijk wrote: > > Still, that works as well, doesn't it? The control flow is basically the > same so the logic in my other message applies. returncmd() doesn't use > exceptions, so you get to dotrap() which already resets exitstatus if >

Re: [v2 PATCH] eval: avoid leaking memory associated with redirections

2018-12-14 Thread Ron Yorston
Herbert Xu wrote: >I thinkg we should just move the stack mark into evaltree for >everybody, like this: Thanks for looking at this. I've tried the revised patch and it does the job. I've ported it to BusyBox ash where it's also effective and passes the test suite. Plus it saves 67 byte, which

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

2018-12-14 Thread Herbert Xu
On Fri, Dec 14, 2018 at 08:02:04AM +, Harald van Dijk wrote: > On 14/12/2018 03:10, Herbert Xu wrote: > > > 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

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

2018-12-14 Thread Harald van Dijk
On 14/12/2018 08:02, Harald van Dijk wrote: On 14/12/2018 03:10, Herbert Xu wrote: On Sat, Dec 08, 2018 at 03:45:11PM +, 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

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

2018-12-14 Thread Harald van Dijk
On 14/12/2018 03:10, Herbert Xu wrote: On Sat, Dec 08, 2018 at 03:45:11PM +, 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 =