From patchwork Thu Jun 4 11:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 11587809 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C6F2913 for ; Thu, 4 Jun 2020 11:54:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DF4E20663 for ; Thu, 4 Jun 2020 11:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726175AbgFDLyE (ORCPT ); Thu, 4 Jun 2020 07:54:04 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:37086 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgFDLyD (ORCPT ); Thu, 4 Jun 2020 07:54:03 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1jgoRX-0007g8-Ol; Thu, 04 Jun 2020 21:53:56 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 04 Jun 2020 21:53:55 +1000 Date: Thu, 4 Jun 2020 21:53:55 +1000 From: Herbert Xu To: dash@vger.kernel.org, Joey Hess , 858288@bugs.debian.org Subject: [PATCH] eval: Check nflag in evaltree instead of cmdloop Message-ID: <20200604115355.GA13954@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org This patch moves the nflag check from cmdloop into evaltree. This is so that nflag will be in force even if we enter the shell via a path other than cmdloop, e.g., through sh -c. Reported-by: Joey Hess Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index d10be38..9476fbb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -213,6 +213,9 @@ evaltree(union node *n, int flags) setstackmark(&smark); + if (nflag) + goto out; + if (n == NULL) { TRACE(("evaltree(NULL) called\n")); goto out; diff --git a/src/main.c b/src/main.c index 7a28534..5c49fdc 100644 --- a/src/main.c +++ b/src/main.c @@ -233,7 +233,7 @@ cmdloop(int top) out2str("\nUse \"exit\" to leave shell.\n"); } numeof++; - } else if (nflag == 0) { + } else { int i; job_warning = (job_warning == 2) ? 1 : 0;