zsh-users
 help / color / mirror / code / Atom feed
* array to braced list conversion ?
@ 2000-09-06  8:45 jarausch
  2000-09-06  9:05 ` Andrej Borsenkow
  2000-09-06  9:06 ` Peter Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: jarausch @ 2000-09-06  8:45 UTC (permalink / raw)
  To: zsh-users


Hi all,

Is there a simple possibility to convert an array
to a brace delimited list?

E.g.

set +A LIST a b c

how can I get the analog of

ls /usr/local/bin/{a,b,c}
using LIST ?

Thanks for any hints

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: array to braced list conversion ?
  2000-09-06  8:45 array to braced list conversion ? jarausch
@ 2000-09-06  9:05 ` Andrej Borsenkow
  2000-09-06  9:06 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Andrej Borsenkow @ 2000-09-06  9:05 UTC (permalink / raw)
  To: jarausch, zsh-users

> 
> Hi all,
> 
> Is there a simple possibility to convert an array
> to a brace delimited list?
> 
> E.g.
> 
> set +A LIST a b c
> 
> how can I get the analog of
> 
> ls /usr/local/bin/{a,b,c}
> using LIST ?
> 

list=(a b c)
ls /usr/local/bin/$^list

-andrej


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: array to braced list conversion ?
  2000-09-06  8:45 array to braced list conversion ? jarausch
  2000-09-06  9:05 ` Andrej Borsenkow
@ 2000-09-06  9:06 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2000-09-06  9:06 UTC (permalink / raw)
  To: Zsh users list

> Is there a simple possibility to convert an array
> to a brace delimited list?
> 
> E.g.
> 
> set +A LIST a b c
> 
> how can I get the analog of
> 
> ls /usr/local/bin/{a,b,c}
> using LIST ?

The answer to the second question isn't the same as the answer to the
first.  The answer to the second is

ls /usr/local/bin/${^LIST}

which turns on RC_EXPAND_PARAM for the word being evaluated.


If you want a real brace delimited list for some reason, you can do
something like:

eval ls /usr/local/bin/\{${(qj.,.)LIST}\}

The stuff at the end produces the braced expression you want by joining the
array with commas, `(j.,.)'.  The extra (q) adds quotes so that
metacharacters inside $LIST will not be treated specially when the eval
takes place.  The eval is necessary to get the braced expression to be
evaluated as such instead of as literal text.  If there's a way of doing it
without the eval, it doesn't occur to me at the moment.  But that's
probably not what you need anyway.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-09-06  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-06  8:45 array to braced list conversion ? jarausch
2000-09-06  9:05 ` Andrej Borsenkow
2000-09-06  9:06 ` Peter Stephenson

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).