From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17071 invoked by alias); 9 Jun 2010 15:29:42 -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: 28014 Received: (qmail 27672 invoked from network); 9 Jun 2010 15:29:40 -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: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) MIME-Version: 1.0 In-Reply-To: <15865.1276088859@csr.com> References: <15865.1276088859@csr.com> Date: Wed, 9 Jun 2010 07:34:47 -0700 Message-ID: Subject: Re: PATCH: bug in ${(z)...} with newlines From: Bart Schaefer To: Zsh hackers list Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jun 9, 2010 at 6:07 AM, Peter Stephenson wrote: > This must be a bug, mustn't it? > > % foo=$'one\ntwo' > % print ${(z)foo} > one ; two I'm pretty sure that's intentional, so that when the newline is removed by splitting, the join is still a semantically equivalent shell expression. Otherwise you can't do stuff like this: foo=(${(q)${(z)foo}}) bar=time for word in $foo do if [[ $word == '\;' ]] then bar+=($word time) else bar+=($word) fi done eval $bar In fact if newline is not replaced with semicolon by (z), I think it becomes impossible to find command words by searching through the resulting array. > As far as splitting arguments goes, the newline is just whitespace. Yes, but (z) is really for parsing, not merely splitting.