From patchwork Thu Mar 15 10:27:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10284203 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 B7FA4602BD for ; Thu, 15 Mar 2018 10:27:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A97FC289A2 for ; Thu, 15 Mar 2018 10:27:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E1F2289A9; Thu, 15 Mar 2018 10:27:53 +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=-5.4 required=2.0 tests=BAYES_00,FAKE_REPLY_C, 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 A0BA7289A2 for ; Thu, 15 Mar 2018 10:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbeCOK1v (ORCPT ); Thu, 15 Mar 2018 06:27:51 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:57342 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbeCOK1v (ORCPT ); Thu, 15 Mar 2018 06:27:51 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.84_2 #2 (Debian)) id 1ewQ6h-0002Kr-M7; Thu, 15 Mar 2018 18:27:35 +0800 Received: from herbert by gondobar with local (Exim 4.84_2) (envelope-from ) id 1ewQ6c-0008MD-OS; Thu, 15 Mar 2018 18:27:30 +0800 Date: Thu, 15 Mar 2018 18:27:30 +0800 From: Herbert Xu To: Harald van Dijk Cc: martijn@inlv.org, dash@vger.kernel.org Subject: Re: Expansion-lookalikes in heredoc delimiters Message-ID: <20180315102730.GA32076@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5dc6db2b-44d8-3be7-302f-15a620aaaa2f@gigawatt.nl> X-Newsgroups: apana.lists.os.linux.dash Organization: Core User-Agent: Mutt/1.5.23 (2014-03-12) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Harald van Dijk wrote: > > Changing dash to support this would in my opinion be unreasonable, as it > would require a total rewrite of the parser. I don't think it's that hard. ---8<--- Subject: parser: Fix backquote support in here-document EOF mark Currently using backquotes in a here-document EOF mark is broken because dash tries to do command substitution on it. This patch fixes it by checking whether we're looking for an EOF mark during tokenisation. Reported-by: Harald van Dijk Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 382658e..283ed63 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1012,6 +1012,11 @@ quotemark: } break; case CBQUOTE: /* '`' */ + if (checkkwd & CHKEOFMARK) { + USTPUTC('`', out); + break; + } + PARSEBACKQOLD(); break; case CEOF: