From patchwork Fri Mar 23 16:05:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn Dekker X-Patchwork-Id: 10305045 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 E0FA660384 for ; Fri, 23 Mar 2018 16:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB80E28FF3 for ; Fri, 23 Mar 2018 16:06:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C014728FF5; Fri, 23 Mar 2018 16:06:09 +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=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI 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 01A1628FF3 for ; Fri, 23 Mar 2018 16:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbeCWQGH (ORCPT ); Fri, 23 Mar 2018 12:06:07 -0400 Received: from kahlil.inlv.org ([37.59.109.123]:36498 "EHLO kahlil.inlv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbeCWQGF (ORCPT ); Fri, 23 Mar 2018 12:06:05 -0400 Received: from breedzicht.local (inlv.demon.nl [212.238.240.159]) (authenticated bits=0) by kahlil.inlv.org (8.14.9/8.14.4) with ESMTP id w2NG5rh4005652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 23 Mar 2018 17:05:53 +0100 Subject: [PATCH v2] don't record empty IFS scan regions if not debugging From: Martijn Dekker To: Herbert Xu Cc: Harald van Dijk , dash@vger.kernel.org References: <20180323043732.GA30910@gondor.apana.org.au> <22bf1638-9a0b-74ce-8f31-a52883f21184@inlv.org> <20180323105847.GB32220@gondor.apana.org.au> Message-ID: <2681a80b-2ff8-1b63-b699-9895a064a4ad@inlv.org> Date: Fri, 23 Mar 2018 17:05:53 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: 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 23-03-18 om 15:34 schreef Martijn Dekker: > Op 23-03-18 om 11:58 schreef Herbert Xu: >> Thanks, the problem here is that we need to set c to 0 not just >> when quoted is true but also if sep is 0 since both imply that >> field splitting is disabled. Here is an second revision which >> should fix this by checking (quoted || !sep) instead of just >> quoted when determining whether we're doing field expansion in $*. > > FWIW, this passes all my tests. But dash is still recording empty IFS scan regions with nothing for IFS to split. That still seems strange to me. It's true that this behaviour has helped expose and fix some bugs in this instance. However, by the same token, other (future) bugs might be exposed by avoiding illogical behaviour. So how about having it both ways? If DEBUG is defined, record empty split regions. If not, don't waste cycles doing so. - M. diff --git a/src/expand.c b/src/expand.c index c14350c..d6c7946 100644 --- a/src/expand.c +++ b/src/expand.c @@ -774,7 +774,12 @@ record: if (!quoted) goto end; } - recordregion(startloc, expdest - (char *)stackblock(), quoted); +#ifndef DEBUG + if (varlen > 0) +#endif + recordregion(startloc, + expdest - (char *)stackblock(), + quoted); goto end; }