Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: exit does not exit in traps triggered within functions
- X-seq: zsh-workers 47501
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Michaël Cadilhac <michael@xxxxxxxxxxxxx>
- Subject: Re: exit does not exit in traps triggered within functions
- Date: Sun, 25 Oct 2020 13:56:37 -0700
- Archived-at: <https://zsh.org/workers/47501>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/CAH%2Bw%3D7ZuihWFsyZYmi36SUugVNGpqAN1xxvu3w11hKdggC-gKQ%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-oi1-f179.google.com) smtp.remote-ip=209.85.167.179; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=NtFhdDAgs8GdxCsW1M5TxyT6Fm1MriDlX7DS0Lgf9Nw=; b=R/Ip3Rul8GVd8vYu03ejvObjtodEmXR/OFuhzlgzWKo6q57RjhFSMumh0LcQccOrZu lXyyoQ7VpX3u34lv6aVlSpQXy9GmPU8kqeOzvmRFrU8CzebDEUFBz96WSw+Jlho+JVdR H7dd585vX/opmy4EjsN7QVCFl6J+LRdnQ8vIMmoxQilQei69lFlMwuIdhU4sB3EQQ4KS A+2wEiyAOezWA6svEQrscqO0CAjVJtykj0gJIdr6ydmpowSOq2JaIv3dEY+36wA/eXm3 WfNX2DXhdxslvyPNuB4/FA3rH7vmJb/ibuXX3CivOVR+rbRTUvN8pIXtYjiy+0Z02oYZ KU5g==
- In-reply-to: <CADt3fpMyZA4FFs9tFmLV1Oy+M_ROxOj3RzuPmCbueJSsR8GrUQ@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <CADt3fpMyZA4FFs9tFmLV1Oy+M_ROxOj3RzuPmCbueJSsR8GrUQ@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
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@xxxxxxxxxxxxx> 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
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author