Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
exit does not exit in traps triggered within functions
- X-seq: zsh-workers 47500
- From: Michaël Cadilhac <michael@xxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: exit does not exit in traps triggered within functions
- Date: Sun, 25 Oct 2020 15:19:44 -0500
- Archived-at: <https://zsh.org/workers/47500>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/CADt3fpMyZA4FFs9tFmLV1Oy%2BM_ROxOj3RzuPmCbueJSsR8GrUQ%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (cadilhac.name) smtp.remote-ip=163.172.56.42; dmarc=none header.from=cadilhac.name; arc=none
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=cadilhac.name; h= mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; s=default; bh=0BqK1huUnUACr6/JV6eegT Ee/Qk=; b=SUi/B0KgMbcn5rrmMgQn4VRGNzqEETOrYF+r7vsKzexZzi8Wcb7uIT RES64bfl5/qG61+2UuFWrILFqfPayZZkz463d8la6EWn4YL5d8jQZT3p+WpDlmaI vG6nT3Z3FA5pqiqWbqaOmNzP37jy3H2foUmxRyvpOpJUY2oTjRVNSzIUkX/o2EXa CbuiAhpcT+QzVOuwej9PvZTyZ+91fZccIXKMbk0YmXrCN1CDxt3u8bkkRIGyYAiq bOh1llERNlH762YgnK95qJm4C2Lx/I1HdMgadoMDPEFKR4p4wsjDeVHdH+Qwdmga sRZcusGLTmEOVL2R5T+9frXuP6xx5CbQ==
- Domainkey-signature: a=rsa-sha1; c=nofws; d=cadilhac.name; h= mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; q=dns; s=default; b=TxTCCc9MmV70u95W VLDnR4mjL3SRJlh/Yg9DU3OPBUmX5BuXwUtRG/PsYgySvNNcY05vT0Lgzzxx87+o FUqfFuoql7XrUbkVionS62ubk0UXzS8sCXgHxeNr4dzn7qeJiEqO7H+wE536yxRT qBHQ9rfHYI5Pq76xRoS4zDt390wdWue+wIHsGCdIuahKtjjJN+R8dDPB97SUHp3m Omgr8PbUivrUVMQazIlLkK5bGrgljyChfJjAxT1udP2/HmilOs0dAwiQQ6PmYluX m6sYzu7zrloN+yDAfEmUz5kDh8bW5zS0znuvyFJOK4gjTOJhvH61+MMhPtKLYT2v 8V4GwQ==
- 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>
- Sender: zsh-workers-request@xxxxxxx
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