zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Michaël Cadilhac" <michael@cadilhac.name>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: exit does not exit in traps triggered within functions
Date: Sun, 25 Oct 2020 13:56:37 -0700	[thread overview]
Message-ID: <CAH+w=7ZuihWFsyZYmi36SUugVNGpqAN1xxvu3w11hKdggC-gKQ@mail.gmail.com> (raw)
In-Reply-To: <CADt3fpMyZA4FFs9tFmLV1Oy+M_ROxOj3RzuPmCbueJSsR8GrUQ@mail.gmail.com>

This was previously discussed in the thread "Bug with traps and exit"
which started in January 2019 and proceeded sporadically through
January 2020.

There was discussion of regression tests but no patch proposed, as far
as I can tell.

On Sun, Oct 25, 2020 at 1:20 PM Michaël Cadilhac <michael@cadilhac.name> wrote:
>
> Hello,
>
> Users at Unix.StackExchange suggested that I forward a question of
> mine appearing here [1], as a potential bug.
>
> Consider these two examples, the second contributed by Stéphane Chazelas:
>
> $ zsh -c 'trap "exit 1; echo X" TERM; f() { kill -TERM $$; echo Y; }; f'
> Y
> $ zsh -c 'trap "exit 1; echo X" EXIT; f() { exit;          echo Y; }; f'
> X
>
> In the first case, the exit in the trap causes the trap to end, but
> f() continues executing—but does not return.  The return value of the
> program is 1.
>
> In the second case, the exit in the trap does not cause the trap to
> end immediately, the trap finishes and does not return, and the return
> value of the program is 0.
>
> As far as I understand, the expected behavior, which BASH displays, is
> for these two scripts to print nothing.
>
> Tested on zsh 5.5.1 and 5.8.
>
> Thanks.
>
> 1: https://unix.stackexchange.com/questions/616217/why-does-zsh-finish-executing-a-function-after-exit-was-called-from-a-trap
>


      reply	other threads:[~2020-10-25 20:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-25 20:19 Michaël Cadilhac
2020-10-25 20:56 ` Bart Schaefer [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to='CAH+w=7ZuihWFsyZYmi36SUugVNGpqAN1xxvu3w11hKdggC-gKQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=michael@cadilhac.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).