From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6231 invoked by alias); 25 May 2010 13:32:00 -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: 27972 Received: (qmail 2330 invoked from network); 25 May 2010 13:31:58 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.fr does not designate permitted sender hosts) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=dYtVl6x24sdg7xQXA5XH62SbO6rg9o2KZbACcVpTKr0eJgiK7khvurxTAslxBmNoXS45Ny00//+b200Xq5xvjAnPq6G6wJekGsgzgnTqILLgO0OYj4MvG/Ec94M+EwGQZEvyFaSJCyqOIN3jdxAIAtde7Z6zo6NEFfExAQX0Rxk= ; X-Yahoo-SMTP: V1UR0WuswBDVD1eFhM33188Ir8ciBckz4W8ZMsAh X-YMail-OSG: Wq3_qkUVM1kXOY7kcNYn_2RtgoOEdGxsKRv8iOdso.nBAVbZYyPUE9mvuWryiWb3qSZ0OApWHexqKEaUzF.AYPpk.9iTVYUmzoaoVm7NG9l6ZbjQwTzEr4.KmiPuLxRZ6mH5gmLXIR1ZnYYxVixSIJbmvISXHMxJcPti8CU.Pb5A7BxmQEDmVPnNhWKbPkKW4fxmUUyQb8ByIBxIdMokn9boAtEF6n4ipd49liFI5fM_ X-Yahoo-Newman-Property: ymail-3 Date: Tue, 25 May 2010 14:25:13 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: ${(q)...} for newline Message-ID: Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <10739.1274644720@pws-pc> <201005232045.o4NKjdLO027329@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201005232045.o4NKjdLO027329@pws-pc.ntlworld.com> User-Agent: Mutt/1.5.16 (2007-09-19) 2010-05-23 21:45:39 +0100, Peter Stephenson: > Peter Stephenson wrote: > > Param-style simple (i.e. backslash) quoting of a newline appends a real > > newline in double quotes. It seems to me it would occasion far fewer > > surprises if this never output a literal newline, so this uses $'\n'. > > Also, would I be right in thinking this is an accident waiting to > happen? > > % foo=(one '' three) > % print ${(q)foo} > one three > > Certainly > > % printf "%q\n" '' > > > which uses the same quoting internally is incompatible with what bash > does (it outputs ''). It looks like in both cases (and all explicit > uses of backslash-quoting --- completion is different) empty strings > might be better turned into an explicit ''. [...] Not in the first case though, as array expansion removes the empty elements. But in "${(@q)foo}" yes maybe, at least to be consistent with bash and ksh93 printf %q. $ zsh -c 'a=(a "" b); printf "<%s>\n" ${(q)a}' $ zsh -c 'a=(a "" b); printf "<%s>\n" "${(q@)a}"' <> -- Stephane