From patchwork Wed Dec 31 20:56:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 5556171 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1D25EBF6C3 for ; Wed, 31 Dec 2014 20:56:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05FAD2014A for ; Wed, 31 Dec 2014 20:56:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE4EB20145 for ; Wed, 31 Dec 2014 20:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbaLaU4J (ORCPT ); Wed, 31 Dec 2014 15:56:09 -0500 Received: from helcar.apana.org.au ([209.40.204.226]:55121 "EHLO helcar.apana.org.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751296AbaLaU4J (ORCPT ); Wed, 31 Dec 2014 15:56:09 -0500 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by fornost.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1Y6QJK-0003KR-Uy; Thu, 01 Jan 2015 07:56:06 +1100 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1Y6QJJ-0003X2-RG; Thu, 01 Jan 2015 07:56:05 +1100 Date: Thu, 1 Jan 2015 07:56:05 +1100 From: Herbert Xu To: Juergen Daubert Cc: dash@vger.kernel.org Subject: [EXPAND] Fixed "$@" expansion when EXP_FULL is false Message-ID: <20141231205605.GA32563@gondor.apana.org.au> References: <20141231180330.GA32534@jue.netz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141231180330.GA32534@jue.netz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Dec 31, 2014 at 07:03:30PM +0100, Juergen Daubert wrote: > Hi, > > today I tried to use dash from git as /bin/sh and run in a lot of > problem I don't see with stable version 0.5.8. > After some investigations I narrowed it down to commit > > 3c06acdac0b1ba0e0acdda513a57ee6e31385dce > [EXPAND] Split unquoted $@/$* correctly when IFS is set but empty > > and related following to expand.c > > > It seems that the changes to dash triggers, among others, some problem > with libtool. > > As examples I've attached build logs for libpixman and kbd, there are a > lot other builds that failed as well. If you need more, please let me > know. Thanks for the report. This patch should fix the problem. -- >8 -- The commit 3c06acdac0b1ba0e0acdda513a57ee6e31385dce ([EXPAND] Split unquoted $@/$* correctly when IFS is set but empty) broke the case where $@ is in quotes and EXP_FULL is false. In that case we should still emit IFS as field splitting is not performed. Reported-by: Juergen Daubert Signed-off-by: Herbert Xu Cheers, diff --git a/src/expand.c b/src/expand.c index dfb3f0e..b2d710d 100644 --- a/src/expand.c +++ b/src/expand.c @@ -901,6 +901,7 @@ varvalue(char *name, int varflags, int flags, int *quotedp) int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL; ssize_t len = 0; + sep = (flags & EXP_FULL) << CHAR_BIT; syntax = quoted ? DQSYNTAX : BASESYNTAX; switch (*name) { @@ -931,16 +932,14 @@ numvar: expdest = p; break; case '@': - sep = 0; - if (quoted) + if (quoted && sep) goto param; /* fall through */ case '*': - sep = ifsset() ? ifsval()[0] : ' '; - if (!quoted) { + if (quoted) + sep = 0; + sep |= ifsset() ? ifsval()[0] : ' '; param: - sep |= (flags & EXP_FULL) << CHAR_BIT; - } sepc = sep; *quotedp = !sepc; if (!(ap = shellparam.p))