From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3661 invoked by alias); 25 May 2010 14:48:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27974 Received: (qmail 17476 invoked from network); 25 May 2010 14:48:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 25 May 2010 15:48:24 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: ${(q)...} for newline Message-ID: <20100525154824.49616502@csr.com> In-Reply-To: References: <10739.1274644720@pws-pc> <201005232045.o4NKjdLO027329@pws-pc.ntlworld.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 May 2010 14:48:24.0289 (UTC) FILETIME=[53BF0510:01CAFC19] X-Scanned-By: MailControl A_09_40_00 (www.mailcontrol.com) on 10.68.0.118 On Tue, 25 May 2010 14:25:13 +0100 Stephane Chazelas wrote: > 2010-05-23 21:45:39 +0100, Peter Stephenson: > > Also, would I be right in thinking this is an accident waiting to > > happen? > > > > % foo=(one '' three) > > % print ${(q)foo} > > one three > > Not in the first case though, as array expansion removes the > empty elements. I don't think that argument really works... consider: % foo=(one '' three) % print ${(j.X.)foo} oneXXthree In other words, flags are applied before empty elements are stripped. The same goes for most transformations on array elements, whether zsh-specific or otherwise; I don't see why (q) should be different. However, we don't actually say in the (already long) manual entry giving the rules for variable expansion at what part either quoting or empty element removal takes place. The latter appears to be the last thing of all, i.e. at the point where we decide to insert this into the list of arguments (or otherwise). I should probably concoct something. Bart wrote > However, I suggest that (q-) continue to use the literal quoted newline. Right, it's really there as minimal quoting for human readability. -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom