From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26443 invoked by alias); 23 May 2010 20:46:12 -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: 27966 Received: (qmail 6338 invoked from network); 23 May 2010 20:46:05 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.49 as permitted sender) Message-Id: <201005232045.o4NKjdLO027329@pws-pc.ntlworld.com> From: Peter Stephenson To: zsh-workers@zsh.org (Zsh hackers list) Subject: Re: ${(q)...} for newline In-Reply-To: Message from Peter Stephenson of "Sun, 23 May 2010 20:58:40 BST." <10739.1274644720@pws-pc> Date: Sun, 23 May 2010 21:45:39 +0100 X-Cloudmark-Analysis: v=1.1 cv=1ggfb5FlKZQUfF3vzm9UBYZ2uTfLsbs/8dSljwg5+mE= c=1 sm=0 a=wbKXeunVgZ0A:10 a=DogomfpGjd0A:10 a=NLZqzBF-AAAA:8 a=4RnPbB-pJCTO1-WqDdAA:9 a=-HUt-yEvSRe4gyuFFyUldoP9dnYA:4 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 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 ''. Is there a case where this breaks something? I can't see one unless you're explicitly relying on a particular result from quoting, which seems an unhealthy thing to do. However, there may be special cases I haven't thought of (there usually are with quoting). -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/