From patchwork Thu Nov 29 15:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn Dekker X-Patchwork-Id: 10704779 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A554213AD for ; Thu, 29 Nov 2018 15:45:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95AF52EF63 for ; Thu, 29 Nov 2018 15:45:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A00B2EF67; Thu, 29 Nov 2018 15:45:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AF522EF63 for ; Thu, 29 Nov 2018 15:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728919AbeK3CvJ (ORCPT ); Thu, 29 Nov 2018 21:51:09 -0500 Received: from kahlil.inlv.org ([37.59.109.123]:39244 "EHLO kahlil.inlv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728363AbeK3CvI (ORCPT ); Thu, 29 Nov 2018 21:51:08 -0500 Received: from breedzicht.fritz.box (inlv.demon.nl [82.161.110.186]) (authenticated bits=0) by kahlil.inlv.org (8.15.2/8.15.2) with ESMTPSA id wATFjK88006731 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 29 Nov 2018 16:45:20 +0100 Subject: [PATCH] clear_traps: reset savestatus From: Martijn Dekker To: DASH shell mailing list References: <0b455c38-b06d-6738-7656-5ad6ef821dc8@inlv.org> Message-ID: Date: Thu, 29 Nov 2018 16:45: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: <0b455c38-b06d-6738-7656-5ad6ef821dc8@inlv.org> Content-Language: en-GB Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Op 27-11-18 om 17:24 schreef Martijn Dekker: > Big bad bug: it appears that subshells always return status 0 in traps. As posted elsewhere, looks like the problem is simply that savestatus ("/* exit status of last command outside traps */") isn't reset to -1 upon resetting traps when forking a subshell. Reposting patch for Patchwork purposes: Thanks, - M. diff --git a/src/trap.c b/src/trap.c index ab0ecd4..7740955 100644 --- a/src/trap.c +++ b/src/trap.c @@ -168,6 +168,7 @@ clear_traps(void) } } trapcnt = 0; + savestatus = -1; INTON; }