From patchwork Sat May 5 15:21:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10382193 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.web.codeaurora.org (Postfix) with ESMTP id CD1C56053F for ; Sat, 5 May 2018 15:21:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADE1728989 for ; Sat, 5 May 2018 15:21:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F29F29166; Sat, 5 May 2018 15:21:14 +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 EF3AD28989 for ; Sat, 5 May 2018 15:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbeEEPVN (ORCPT ); Sat, 5 May 2018 11:21:13 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:35732 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeEEPVM (ORCPT ); Sat, 5 May 2018 11:21:12 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1fEyzn-0006s6-25; Sat, 05 May 2018 23:21:11 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1fEyzm-00062s-TE; Sat, 05 May 2018 23:21:10 +0800 Date: Sat, 5 May 2018 23:21:10 +0800 From: Herbert Xu To: dash@vger.kernel.org Subject: main: Only set savestatus in exitcmd Message-ID: <20180505152110.qrqv4we3gtxg6fij@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently exitcmd sets exitstatus and then savestatus if the latter was previously set. In fact, as exitcmd always raises an exception and will either end up in the setjmp call in main() or exitshell(), where exitstatus is always replaced by savestatus if set, we only need to set savestatus. Signed-off-by: Herbert Xu diff --git a/src/main.c b/src/main.c index fcd3e7d..9f03717 100644 --- a/src/main.c +++ b/src/main.c @@ -339,13 +339,8 @@ exitcmd(int argc, char **argv) if (stoppedjobs()) return 0; - if (argc > 1) { - int status = number(argv[1]); - - exitstatus = status; - if (savestatus >= 0) - savestatus = status; - } + if (argc > 1) + savestatus = number(argv[1]); exraise(EXEXIT); /* NOTREACHED */