From patchwork Thu Mar 22 02:40:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn Dekker X-Patchwork-Id: 10300771 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 CBA57600CC for ; Thu, 22 Mar 2018 02:41:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF606298A8 for ; Thu, 22 Mar 2018 02:41:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B6829911; Thu, 22 Mar 2018 02:41:00 +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 B7034298A8 for ; Thu, 22 Mar 2018 02:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751717AbeCVCk7 (ORCPT ); Wed, 21 Mar 2018 22:40:59 -0400 Received: from kahlil.inlv.org ([37.59.109.123]:53152 "EHLO kahlil.inlv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbeCVCk6 (ORCPT ); Wed, 21 Mar 2018 22:40:58 -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 w2M2euJd005812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 22 Mar 2018 03:40:56 +0100 To: DASH shell mailing list From: Martijn Dekker Subject: [PATCH] don't record empty IFS scan regions Message-ID: Date: Thu, 22 Mar 2018 03:40:56 +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 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 evalvar() records empty expansion results (varlen == 0) as string regions that need to be scanned for IFS characters. This is pointless, because there is nothing to split. This patch fixes the bug that, given no positional parameters, unquoted $@ and $* incorrectly generate one empty field (they should generate no fields). Apparently that was a side effect of the above. - M. diff --git a/src/expand.c b/src/expand.c index 705fef7..03a9b0c 100644 --- a/src/expand.c +++ b/src/expand.c @@ -771,7 +771,7 @@ vsplus: if (subtype == VSNORMAL) { record: - if (!easy) + if (!easy || varlen == 0) goto end; recordregion(startloc, expdest - (char *)stackblock(), quoted); goto end;