From patchwork Mon Apr 29 14:13:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Merinov X-Patchwork-Id: 10921855 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 F332B14DB for ; Mon, 29 Apr 2019 14:20:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6E9C289AB for ; Mon, 29 Apr 2019 14:20:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB4CE289B2; Mon, 29 Apr 2019 14:20:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 5EB6A289A7 for ; Mon, 29 Apr 2019 14:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbfD2OUq (ORCPT ); Mon, 29 Apr 2019 10:20:46 -0400 Received: from mail.inango-systems.com ([213.136.71.184]:33190 "EHLO mail.inango-sw.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbfD2OUq (ORCPT ); Mon, 29 Apr 2019 10:20:46 -0400 X-Greylist: delayed 381 seconds by postgrey-1.27 at vger.kernel.org; Mon, 29 Apr 2019 10:20:45 EDT Received: from localhost (localhost [127.0.0.1]) by mail.inango-sw.com (Postfix) with ESMTP id C487F7A249C for ; Mon, 29 Apr 2019 17:14:23 +0300 (IDT) Received: from mail.inango-sw.com ([127.0.0.1]) by localhost (mail.inango-sw.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id q9J3keEV2CBA; Mon, 29 Apr 2019 17:14:21 +0300 (IDT) Received: from localhost (localhost [127.0.0.1]) by mail.inango-sw.com (Postfix) with ESMTP id CD7EB7A2497; Mon, 29 Apr 2019 17:14:21 +0300 (IDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.inango-sw.com CD7EB7A2497 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inango-systems.com; s=45A440E0-D841-11E8-B985-5FCC721607E0; t=1556547261; bh=7J8Gu2bHRRYhPW2nzo1fmFoyA7DsAuput+xjrLvAITs=; h=From:To:Date:Message-Id; b=BfDg6WVEwGALBa22hQzyUIkmk1cwSbmod5tCxCj6Q3OkL1gYk9VTd/odBX9cakFCz 4IhAKjJfJ5nJ3VWlAlG4YTdIVr/7y4we8pp/3b5uxHhRLYjmngiWF6CZsezZE1Rpfz /YtHHTZ9GnYTBLF8seE6c6wDbeW0Lw7Us28CTggrvZetTJCMa3dAgbODAPx3L6qW2x O3fltp3BpMhWhKiKJKTrO3PRsBSEhighrXYhMPZHYgD0ezRn/s7tjegtrzzk9LcbUe AoePjZ3fLdDapBK3h4dKHNowqdxzVGGtj/P/Mn9RDLDS0RKFRBMfhqaTEBp2kSYavp t4WrJ2NWDiP/g== X-Virus-Scanned: amavisd-new at inango-sw.com Received: from mail.inango-sw.com ([127.0.0.1]) by localhost (mail.inango-sw.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 33LCx0br-ifM; Mon, 29 Apr 2019 17:14:21 +0300 (IDT) Received: from nmerinov.inango-sw (unknown [194.60.247.123]) by mail.inango-sw.com (Postfix) with ESMTPSA id 3FBC77A2492; Mon, 29 Apr 2019 17:14:21 +0300 (IDT) From: Nikolai Merinov To: dash@vger.kernel.org Cc: os@inango-systems.com, Nikolai Merinov Subject: [PATCH] expand: Fix trailing newlines processing in backquote expanding Date: Mon, 29 Apr 2019 19:13:37 +0500 Message-Id: <20190429141337.6804-1-n.merinov@inango-systems.com> X-Mailer: git-send-email 2.17.1 Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to POSIX.1-2008 we should remove newlines only at the end of the substitution. Newlines-only substitions causes dash to remove newlines before beggining of the substitution. The following code: cat <2" instead of expected "12". This patch fixes trailing newlines processing in backquote expanding. Signed-off-by: Nikolai Merinov --- src/expand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expand.c b/src/expand.c index af9cac9..1b1f95e 100644 --- a/src/expand.c +++ b/src/expand.c @@ -525,7 +525,7 @@ read: /* Eat all trailing newlines */ dest = expdest; - for (; dest > (char *)stackblock() && dest[-1] == '\n';) + for (; dest > ((char *)stackblock() + startloc) && dest[-1] == '\n';) STUNPUTC(dest); expdest = dest;