From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8999 invoked from network); 15 Apr 2022 22:27:34 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Apr 2022 22:27:34 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1650061654; b=JeDkF6yc8rfYSrijAlLV4UwfDFEXBzK/FIQNO6dZfSo7pRFh2UblBNSONPc8nQO6wPQT/ASO1G M2ijGYerU8navWBtdFtlNAByLM0PVWy/a+RHXIte7Va9sAiIvQs5B5eAullGYLxkH7k91oWTJa R1ZftV+AktNwbW4oEIFknqrVNkNj7ZaRavbq3RXXeRWt66nCCxv+14jW0wX+AHhyzFKkRQmc0b ju/tBpLNXhKwHGKmB/hzW7iCJ9I43j0DO/MDFNKRsNG+UZHt6kYNGejvT70J8unKLfTa+BFpyz 8W8bSey2muMDv05etf1gZQRq4rg7J9zvMOR8pfuR1EReJQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f47.google.com) smtp.remote-ip=209.85.218.47; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1650061654; bh=BuDy6DTSJZbwo6FukQTneHZkAZG90mfRreFMuC68KPI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=OUadg9GrdgmEyS+yDKVqSoW/FZAXIcwUCRxxElcIbaQDhcO4f3+k8x7QNUwmTnBwHhZwFZeDJC XEEYey0WPveP+AscIw2V3Ks9D45a3MKu4PuPO3VExQKgkub+gL5oz7JEG9yN4MXC9bYtjvhDSf Bi1Y8CC5lgi85WzJMORs53X4zfy92FL5gWvyp3cHbkKeDlWzBf876uTcBPcyhmyk48b1MDkVxm ST2J+1xHiFAIB/7O3Ygeq1RSxWlVBfKdl3Ovj2oSL1uL32N+ZqP4nEK6nXjwyoHmZxRT9T1ZSc Wm9mrPeMen3fBl+ZiUG5W1FJlIqGWV63C7l9bfCvmGQPCw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=y/d9RtgBfveIPTWWoz2BqBl8GdAqNiO4tV/2P7unRtk=; b=Il+N2DQi8S7j/J6n9dlf/DfuPC tZCoY7hrQcFBFdzaNgP9Un72DEzqC/K8kdZvbi4Gplbr9435WjTUo6r13vtkq+PGeJC5x1WD4XRdD K9r8XZoT7T3qlUpyeN+a9w9Knhhz2b0eE+GN0T8Du83mfQk/TtgLi60saMKfJsvC6vzkviqNLEm/c pHt1P9r7l7rbIEq67ED84DwzAI6eBhklzwmDTa9HBVdc7MyEYOD4S7T53M2BOw3vyIoLYnpNrrKn8 woVaN7qHapRMUdmXGfWknRoZE6Q+qnskzADbU3AJPbpEckt7/tEKCgZqr1iFYSDvK3iXfnclOQlQ4 LBr5c+tQ==; Received: from authenticated user by zero.zsh.org with local id 1nfUPc-000IcM-5a; Fri, 15 Apr 2022 22:27:32 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f47.google.com) smtp.remote-ip=209.85.218.47; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f47.google.com ([209.85.218.47]:44988) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nfUPN-000IJw-5a; Fri, 15 Apr 2022 22:27:18 +0000 Received: by mail-ej1-f47.google.com with SMTP id u15so17283820ejf.11 for ; Fri, 15 Apr 2022 15:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=y/d9RtgBfveIPTWWoz2BqBl8GdAqNiO4tV/2P7unRtk=; b=qI2c+EKWUtoc2+R0TUPKtw1zGS+iIJzy75y61+hl43tdu2roihEPXTAigUd7dR/Lfi sByqPg2fvrYPBx2z1Kd4M/EHfyA7lVB4sJNhvmRpsGUwDLGufV+ZhGUFXfOuxeCWgjtz 6fLTjI9hKkkSntZ2MtYpalinEbVHAgxIw9xgIVnWGorKN+hrN+O79/2lfGyZulKK23pT lWsM5r1KUmi0yhblI2v7CuD2mWqL/sSGn/gUBzyKBH3dnYqFw8axxCB00DyiZuMKIRRx X2WWh7FnM4lg2zwE0CA7vMpRmL/5pBOYe8VEVnU0GRG6RqYfxT9Z90wvoN/VClwxUunG m8Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=y/d9RtgBfveIPTWWoz2BqBl8GdAqNiO4tV/2P7unRtk=; b=JnjoHre3OeTvzAPjdspjGggMaTU7mw9B2Q88EHrYBANtcVR4oTrqTjdwYVDr2md0Vh qcpPdQ6bLpQ2vlW7jIFlf5onMk8oLpw2x4reXM7ETDb6gmr/ROLW/V/Wi8E0HTMJBDq9 pprNL8jEfWy8LEjAwcgLjfKoA2Hv7Ra3i4r4zuH6Pj1x3YxdjH/F/vnU04eXi3jT9Ts8 QM3DU273Ip9DZEfMlStb8vDt4mhxZ+Ka0ODltzNSndre67Hb8pZvEfM0wl8jzP3/d/Ku c5oZr5njiYSevLdRViAmG3FxSm8WN6v/CfNZy4/NmuiSB4N3axxhWUsL/SwDOzSWC6HZ Woxg== X-Gm-Message-State: AOAM533Po3gP2Ax5qDEtgWuYgDf0GuFsDokg1txudiAcA0EdCCXDnUeP EwvJxFfK26eLtuu6bqiMDB5MiBdmbatUKhjFro6pYMZjq1dkpCVl X-Google-Smtp-Source: ABdhPJwM1TEwuVvtyTco922+13ssTMcJBHu5a1SZLT/w+mDB7C4C2IAkBCAndqSjpBiFm1/cR/5FQrOvGzm7t7pfXYY= X-Received: by 2002:a17:907:2bf4:b0:6e8:93d4:46e9 with SMTP id gv52-20020a1709072bf400b006e893d446e9mr833208ejc.69.1650061636345; Fri, 15 Apr 2022 15:27:16 -0700 (PDT) MIME-Version: 1.0 References: <25170.64465.301441.247673@lwm.klanderman.net> <87fsmk2a03.fsf@lwm.klanderman.net> <87czho2967.fsf@lwm.klanderman.net> <871qy0yzp4.fsf@lwm.klanderman.net> In-Reply-To: From: Bart Schaefer Date: Fri, 15 Apr 2022 15:27:05 -0700 Message-ID: Subject: Re: using trap function to cleanup and exit? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 50071 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Thu, Apr 14, 2022 at 2:29 PM Bart Schaefer wrote: > > [I] would prefer that another set of eyes review > the code change. To expand on that a bit ... The BIN_RETURN branch checks that (trap_return == -2) which is a pretty specific number. exec.c says: * This is only active if we are inside a trap, else its value * is irrelevant. It is initialised to -1 for a function trap and * -2 for a non-function trap and if negative is decremented as * we go deeper into functions and incremented as we come back up. * The value is used to decide if an explicit "return" should cause * a return from the caller of the trap; it does this by setting * trap_return to a status (i.e. a non-negative value). My interpretation is that, since we are in an explicit "exit" rather than an explicit "return", we don't really care how trap_return is set; we're going to force the caller to return, period. However, the test for whether to increment trap_return again on the way out is dependent on trap_state == TRAP_STATE_PRIMED, so if we change trap_state we're never going to increment (or decrement, actually) trap_return again. (It may, however, get restored from a stacked value.) I can imagine there being some side-effect of this from using a mix of "return" and "exit" from traps or from functions that might be called by traps, but have no good idea how to exercise such a code path. I guess I'll go ahead and push this and if someone spots a problem we can do a revision.