From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 f01c0ad3 for ; Sat, 8 Dec 2018 20:23:50 +0000 (UTC) Received: (qmail 29268 invoked by alias); 8 Dec 2018 20:23:32 -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: 43874 Received: (qmail 24571 invoked by uid 1010); 8 Dec 2018 20:23:32 -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.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(37.59.109.123):SA:0(-1.9/5.0):. Processed in 2.651764 secs); 08 Dec 2018 20:23:32 -0000 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | From: Martijn Dekker To: Zsh hackers list Subject: EXIT trap not executed on error Message-ID: <1939278e-89c4-812d-5dea-e836568dc100@inlv.org> Date: Sat, 8 Dec 2018 21:08:45 +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 zsh exits due to an error in a special builtin (e.g. 'set -o bad@option') or in an arithmetic expression in $((...)), the EXIT trap is not executed. Is this a bug? I'm not sure -- I can't find anything relevant in the POSIX spec. But it seems to me like the trap should be executed. All the other shells execute the trap. Emulation modes don't seem to make a difference to this behaviour. $ zsh -c 'trap "echo OK" EXIT; : $((1\\2)); echo OOPS' zsh:1: bad math expression: illegal character: \ (output I would expect: that error message followed by 'OK') - M.