From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24535 invoked from network); 12 Jan 2006 12:20:42 -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 Jan 2006 12:20:42 -0000 Received: (qmail 79229 invoked from network); 12 Jan 2006 12:20:35 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Jan 2006 12:20:35 -0000 Received: (qmail 26005 invoked by alias); 12 Jan 2006 12:20:28 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9829 Received: (qmail 25995 invoked from network); 12 Jan 2006 12:20:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Jan 2006 12:20:28 -0000 Received: (qmail 78114 invoked from network); 12 Jan 2006 12:20:28 -0000 Received: from ykdmp01.yokohama.riken.go.jp (HELO ykdmp01.yokohama.riken.jp) (134.160.82.30) by a.mx.sunsite.dk with SMTP; 12 Jan 2006 12:20:27 -0000 Received: (qmail 78842 invoked by uid 98); 12 Jan 2006 12:20:24 -0000 Received: from 134.160.84.23 by ykdmp01.yokohama.riken.jp (envelope-from , uid 82) with qmail-scanner-1.25 (sophie: 3.04/2.31/3.98. spamassassin: 3.1.0. Clear:RC:1(134.160.84.23):. Processed in 0.027512 secs); 12 Jan 2006 12:20:24 -0000 Received: from unknown (HELO jota.gsc.riken.go.jp) (134.160.84.23) by ykdmp01.yokohama.riken.go.jp with SMTP; 12 Jan 2006 12:20:24 -0000 Received: from [10.64.65.5] (ipm04.gsc.riken.go.jp [134.160.83.74]) by jota.gsc.riken.go.jp (Postfix) with ESMTP id 3637634854DF; Thu, 12 Jan 2006 21:20:24 +0900 (JST) In-Reply-To: References: <36947C4E-7C19-4BB5-A43B-EC8D3EF0713A@jota.gsc.riken.go.jp> <1060112014126.ZM717@candle.brasslantern.com> <6DC50D24-618F-4531-BA06-0F31570283C1@jota.gsc.riken.go.jp> <0852320A-7790-45A1-9BE5-8B7AB27BD107@jota.gsc.riken.go.jp> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: zsh-users@sunsite.dk Content-Transfer-Encoding: 7bit From: Wataru Kagawa Subject: Re: joining array elements Date: Thu, 12 Jan 2006 21:20:24 +0900 To: Peter Stephenson X-Mailer: Apple Mail (2.746.2) I think my example was unclear (Sorry). Basically, I wanted an output that looks like, David Matt Bob[return]Sara[return]Tim I can get it with, foo=$( printf '%s\n' David Matt ${(j:[return]:)usernames} ) with the 'globsubst' option turned off. However, I was trying to incorporate your tip, because I wanted to keep that option turned on. foo=$( printf '%s\n' David Matt ${(j:[return]:)~~usernames} ) gives me no output (with the 'nullglob' option set). Thanks. On 2006/01/12, at 20:54, Peter Stephenson wrote: > Wataru Kagawa wrote: >> Hi Peter, >> >> Thank you for the tip. I would like to place the expansion into a >> variable, however, I am having a trouble. >> >> % usernames=( Bob Sara Tim ) >> % print -R ${(j:[return]:)~~usernames} >> Bob[return]Sara[return]Tim >> >> However, >> >> % foo=$( printf '%s\n' David Matt ${(j:[return]:)~~usernames} ) >> % echo $foo > > What effect are you trying to achieve? The command you show does > exactly what I expect it to. Do you mean you want David and Matt > added > in the same way and the result put in foo? > > usernames2=(David Matt $usernames) > foo=${(j:[return]:)~~usernames2} > > Or do you mean you want the same effect as you get when outputting > David > and Matt using printf, but with all the names, so that foo ends up > being > joined with newlines? > > foo=${(F)usernames2} > > -- > Peter Stephenson Software Engineer > CSR PLC, Churchill House, Cambridge Business Park, Cowley Road > Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 > 692070 > > > Your mail client is unable to display the latest news from CSR. To > access our news copy this link into a web browser: http:// > www.csr.com/email_sig.html