From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43647-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=-0.2 required=5.0 tests=DATE_IN_PAST_12_24, 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 043c21c3 for ; Tue, 9 Oct 2018 01:26:11 +0000 (UTC) Received: (qmail 22475 invoked by alias); 9 Oct 2018 01:25:57 -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: 43647 Received: (qmail 10462 invoked by uid 1010); 9 Oct 2018 01:25:57 -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.275583 secs); 09 Oct 2018 01:25:57 -0000 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | To: Zsh hackers list From: Martijn Dekker Subject: [Bug] Exiting shell from function called by trap handler always produces status 0 Message-ID: Date: Mon, 8 Oct 2018 14:02:23 +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 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit 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) I was able to reproduce this in zsh 5.4.1 and up, and not in 5.3.1 and earlier. Every other shell also exits with status 13. Looping through git commits starting from zsh-5.3.1, I found the commit that introduced this: d7110d8 (41012: Fix premature exit from nested function in EXIT trap). Thanks, - M.