From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43659-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 46313110 for ; Tue, 9 Oct 2018 11:46:44 +0000 (UTC) Received: (qmail 17031 invoked by alias); 9 Oct 2018 11:46:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43659 Received: (qmail 20384 invoked by uid 1010); 9 Oct 2018 11:46:33 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(37.59.109.123):SA:0(-1.9/5.0):. Processed in 2.420445 secs); 09 Oct 2018 11:46:33 -0000 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Subject: Re: [Bug] Exiting shell from function called by trap handler always produces status 0 To: zsh-workers@zsh.org References: <20181009084918eucas1p27dedda10d51beb773ba9175967912d2c~b5IUtvcVK3037630376eucas1p2R@eucas1p2.samsung.com> From: Martijn Dekker Message-ID: <205ea5e4-4dc9-2ebf-9437-0822195e1a9a@inlv.org> Date: Tue, 9 Oct 2018 12:46:20 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181009084918eucas1p27dedda10d51beb773ba9175967912d2c~b5IUtvcVK3037630376eucas1p2R@eucas1p2.samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Op 09-10-18 om 09:49 schreef Peter Stephenson: > On Mon, 2018-10-08 at 14:02 +0100, Martijn Dekker wrote: >> When a trap handler exits the shell using the 'exit' command within a >> function, the shell's exit status is zero even if another exit status >> was given as an argument to the 'exit' command. >> >> $ Src/zsh -c 'fn() { exit 13; }; trap "fn" EXIT' >> $ echo $? >> 0 >> (expected output: 13) > diff --git a/Src/builtin.c b/Src/builtin.c > index c5b319b..b81acdb 100644 [...] This still doesn't fix it. Output identical to above. > + $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT; exit' The extra '; exit' at the end makes it work correctly, but should not be necessary. Thanks, - M.