From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8840 invoked from network); 6 Sep 2000 09:06:55 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 Sep 2000 09:06:55 -0000 Received: (qmail 17208 invoked by alias); 6 Sep 2000 09:06:44 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3411 Received: (qmail 17201 invoked from network); 6 Sep 2000 09:06:43 -0000 Date: Wed, 06 Sep 2000 10:06:14 +0100 From: Peter Stephenson Subject: Re: array to braced list conversion ? In-reply-to: "Your message of Wed, 06 Sep 2000 10:45:00 +0200." <200009060845.KAA98530@numa1.igpm.rwth-aachen.de> To: zsh-users@sunsite.auc.dk (Zsh users list) Message-id: <0G0G006GHJYD27@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > 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 Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070