zsh-users
 help / color / mirror / code / Atom feed
From: Wataru Kagawa <wkagawa@jota.gsc.riken.go.jp>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-users@sunsite.dk
Subject: Re: joining array elements
Date: Thu, 12 Jan 2006 21:20:24 +0900	[thread overview]
Message-ID: <B7631B79-D420-4FDF-8216-5D086E3E72A2@jota.gsc.riken.go.jp> (raw)
In-Reply-To: <EXCHANGE03XUkzni5rW000029dc@exchange03.csr.com>

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 <pws@csr.com>                  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


  reply	other threads:[~2006-01-12 12:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-12  1:22 Wataru Kagawa
2006-01-12  1:41 ` Bart Schaefer
2006-01-12  1:59   ` Wataru Kagawa
2006-01-12  5:17     ` Wataru Kagawa
2006-01-12  9:10       ` Peter Stephenson
2006-01-12 11:44         ` Wataru Kagawa
2006-01-12 11:54           ` Peter Stephenson
2006-01-12 12:20             ` Wataru Kagawa [this message]
     [not found]               ` <10756.1137069559@logicacmg.com>
2006-01-12 13:01                 ` Wataru Kagawa
2006-01-12 13:10               ` Peter Stephenson
2006-01-12 15:16                 ` Wataru Kagawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B7631B79-D420-4FDF-8216-5D086E3E72A2@jota.gsc.riken.go.jp \
    --to=wkagawa@jota.gsc.riken.go.jp \
    --cc=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).