dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: DASH shell mailing list <dash@vger.kernel.org>
Subject: Re: EXIT trap handling in subshells broken
Date: Fri, 17 Jan 2020 18:15:32 +0800	[thread overview]
Message-ID: <20200117101532.jlddos2uctne5xk7@gondor.apana.org.au> (raw)
In-Reply-To: <c1a9c062-0917-d3f3-8826-811b5a4fd802@gigawatt.nl>

On Mon, Jan 06, 2020 at 09:57:20PM +0000, Harald van Dijk wrote:
> The problem is not limited to redirections:
>   f() { (trap "echo \$var" EXIT); }
>   var=bad
>   var=ok f
> This prints "bad", when it should print "ok". Here, the local variable is
> dropped not in main(), but during the unwind process.

This works fine for me with the latest git tree.  This is because
reset has now been split into exitreset and reset and variables
are only reset in reset() which is only called if exitshell is
not happening.

As if we're in a subshell we will never take the reset() path
I don't think we need to do anything here at all.

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

  parent reply	other threads:[~2020-01-17 10:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c1a9c062-0917-d3f3-8826-811b5a4fd802@gigawatt.nl>
2020-01-17  8:51 ` Herbert Xu
2020-01-17  9:57   ` [PATCH] redir: Clear saved redirections in subshell Herbert Xu
2020-01-17 15:28     ` [v2 PATCH] " Herbert Xu
2020-01-17 23:11       ` Harald van Dijk
2020-01-19 10:21       ` [v3 " Herbert Xu
2020-01-17 10:15 ` Herbert Xu [this message]
2020-01-17 22:58   ` EXIT trap handling in subshells broken Harald van Dijk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200117101532.jlddos2uctne5xk7@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    --subject='Re: EXIT trap handling in subshells broken' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).