From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13483 invoked from network); 11 Aug 2005 19:41:12 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Aug 2005 19:41:12 -0000 Received: (qmail 35383 invoked from network); 11 Aug 2005 19:41:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Aug 2005 19:41:03 -0000 Received: (qmail 12644 invoked by alias); 11 Aug 2005 19:40:57 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9297 Received: (qmail 12635 invoked from network); 11 Aug 2005 19:40:56 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Aug 2005 19:40:56 -0000 Received: (qmail 34469 invoked from network); 11 Aug 2005 19:40:56 -0000 Received: from dan.emsphone.com (199.67.51.101) by a.mx.sunsite.dk with SMTP; 11 Aug 2005 19:40:48 -0000 Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id j7BJek8p061966 for zsh-users@sunsite.dk; Thu, 11 Aug 2005 14:40:46 -0500 (CDT) (envelope-from dan) Date: Thu, 11 Aug 2005 14:40:46 -0500 From: Dan Nelson To: Zsh Users Subject: Re: Printing arrays for use with $() Message-ID: <20050811194046.GB49463@dan.emsphone.com> References: <20050811161654.GA8200@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050811161654.GA8200@DervishD> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.9i X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 In the last episode (Aug 11), DervishD said: > I have a script which produces a list of files to stdout. It just > prints an array (namely, something like "print -l -- $array" right > now), and I want to use that list in this way: > > whatevercommand $(myscript) > > Obviously the above doesn't work because the spaces in the file > names are not quoted (special character like the square brackets are, > though), but I cannot do this: > > print -l -- ${(qq)array} > > for printing because then even the single quotes are quoted (this > happens too using three and four 'q' flags). Why not use ${(q)array}? You probably also want to use print -r, othersize it will try and parse \-escape codes. dan% a=("file name" single\'quote double\"quote) dan% echo ${(q)a} file\ name single\'quote double\"quote dan% echo ${(qq)a} 'file name' 'single'\''quote' 'double"quote' dan% echo ${(qqq)a} "file name" "single'quote" "double\"quote" dan% print -l -- ${(qq)a} 'file name' 'single'''quote' 'double"quote' dan% print -rl -- ${(qq)a} 'file name' 'single'\''quote' 'double"quote' -- Dan Nelson dnelson@allantgroup.com