From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7014 invoked from network); 12 Feb 2006 07:46:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Feb 2006 07:46:21 -0000 Received: (qmail 90014 invoked from network); 12 Feb 2006 07:46:15 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Feb 2006 07:46:15 -0000 Received: (qmail 9281 invoked by alias); 12 Feb 2006 07:46:13 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22238 Received: (qmail 9271 invoked from network); 12 Feb 2006 07:46:12 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Feb 2006 07:46:12 -0000 Received: (qmail 89697 invoked from network); 12 Feb 2006 07:46:12 -0000 Received: from flock1.newmail.ru (80.68.241.157) by a.mx.sunsite.dk with SMTP; 12 Feb 2006 07:46:11 -0000 Received: (qmail 9425 invoked from network); 12 Feb 2006 07:46:10 -0000 Received: from unknown (HELO cooker.local) (arvidjaar@newmail.ru@83.237.195.165) by smtpd.newmail.ru with SMTP; 12 Feb 2006 07:46:10 -0000 From: Andrey Borzenkov To: zsh-workers@sunsite.dk Subject: Re: [SOLVED] Libtool/zsh quoting problem: a zsh... bug? Date: Sun, 12 Feb 2006 10:46:06 +0300 User-Agent: KMail/1.9.1 References: <20060209233201.GA5875@fargo> <200602111321.48602.arvidjaar@newmail.ru> <20060211181440.GA30984@dot.blorf.net> In-Reply-To: <20060211181440.GA30984@dot.blorf.net> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200602121046.07861.arvidjaar@newmail.ru> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday 11 February 2006 21:14, Wayne Davison wrote: > On Sat, Feb 11, 2006 at 01:21:43PM +0300, Andrey Borzenkov wrote: > > See this thread: ; > > there was an attempt to fix it in 16949 but apparently it was incomplete > > and never went in. > > I just took a look at that code using Peter's old patch as a start, and > the assertion that the quotes have been stripped out is not quite true: > there are still Dnull and Snull characters remaining which indicate that > there used to be a double- or single-quotes present. This allows us to > check the string. An overly simple version is this: > > --- subst.c 6 Feb 2006 11:57:06 -0000 1.44 > +++ subst.c 11 Feb 2006 18:07:23 -0000 > @@ -2012,6 +2012,8 @@ paramsubst(LinkList l, LinkNode n, char > */ > multsub(&val, (aspar ? NULL : &aval), &isarr, NULL); > copied = 1; > + if (spbreak && (*s == Dnull || *s == Snull)) > + spbreak = 0; > } > break; > case ':': > > This will turn off word-splitting if the string started with a single or > a double quote. This is incomplete because the arg may be something > more complicated (such as: 'one' 'two' 'three four'), but it seems > better than what we have now. > I am not at all sure that the above is valid in POSIX shell. The word in ${var+word} is a token, and token is delimited by the first blank; so while you can do ${var+$(any command with blank)} (because command substitution forms token by itself) you apparently cannot do ${var+foo bar baz}. That's said, bash accepts the above just fine and correctly preserves quoting: bash-3.1$ args() > { > while [[ $# -gt 0 ]]; do > echo "$1" > shift > done > } bash-3.1$ args ${var+"foo bar" baz} foo bar baz So assuming my interpretation is correct, we have two options: - - turn the above on only is sh (POSIX?) emulation mode on assumption that multiple words on the right side are invalid anyway - - attempt to fix it to be compatible with bash i.e. correctly preserve individual quoted words. Is it possible to recursively call expansion on rhs word? According to SUS: "word shall be subjected to tilde expansion, parameter expansion, command substitution, and arithmetic expansion." so recursively calling expansion looks the right way to go. > One question I have is what to do about ${=1:"$@"}? In the patch above, > I chose to let the double quotes override the '='. If that is not > desired, change the new "if" to only trigger disallow an spbreak of 2: > > + if (spbreak == 1 && (*s == Dnull || *s == Snull)) > As long as it is documented ... - -andrey -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFD7ue/R6LMutpd94wRAs4KAJ9MWbzrm9d3KLWMUesXus3PMNliAACeM5Zo zFEwjjuV8xmtoEGbr7agYuc= =3Tbz -----END PGP SIGNATURE-----