From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18149 invoked from network); 12 Aug 2005 14:37:37 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Aug 2005 14:37:37 -0000 Received: (qmail 4176 invoked from network); 12 Aug 2005 14:37:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Aug 2005 14:37:30 -0000 Received: (qmail 29583 invoked by alias); 12 Aug 2005 14:37:22 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9305 Received: (qmail 29574 invoked from network); 12 Aug 2005 14:37:21 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Aug 2005 14:37:21 -0000 Received: (qmail 3051 invoked from network); 12 Aug 2005 14:37:21 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 12 Aug 2005 14:37:17 -0000 Received: from candle.brasslantern.com ([71.116.79.190]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IL4008AD5Y2PV0F@vms046.mailsrvcs.net> for zsh-users@sunsite.dk; Fri, 12 Aug 2005 09:37:15 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j7CEbDMK013162 for ; Fri, 12 Aug 2005 07:37:13 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j7CEbDht013161 for zsh-users@sunsite.dk; Fri, 12 Aug 2005 07:37:13 -0700 Date: Fri, 12 Aug 2005 14:37:13 +0000 From: Bart Schaefer Subject: Re: Printing arrays for use with $() In-reply-to: <20050812082909.GB354@DervishD> To: Zsh Users Message-id: <1050812143713.ZM13160@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050811161654.GA8200@DervishD> <1050811163714.ZM2498@candle.brasslantern.com> <20050811170124.GA8279@DervishD> <20050811222847.GA341@DervishD> <1050812022700.ZM12607@candle.brasslantern.com> <20050812082909.GB354@DervishD> Comments: In reply to DervishD "Re: Printing arrays for use with $()" (Aug 12, 10:29am) 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.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 On Aug 12, 10:29am, DervishD wrote: } } > But again all of this assumes you can control the caller, which means } > you could just as easily require IFS=$'\0'. } } Do you mean something like this?: } } IFS=$'\0' du -s `myscript` Yes, except that you need a semicolon ... IFS=$'\0'; du -s `myscript` ... which also means that you probably need to save and restore the old value of IFS. From that standpoint the "eval" is likely better. } I'm thinking about another solution that could be better, since } sometimes I want to manually review the list before passing it to the } command (and the scripts generates a *different* list each time is } called): } } array=(`myscript args`) A potential way to do this would be to have myscript print the entire assignment expression: print -r -- array=\( ${(q)array} \) and then have the caller simply do: eval $(myscript args) } Could I do the above, using 'print -N', and after that forcing } the split in NULLs? I've tested this (doesn't work): } } array=(`print -N -- $list`) This doesn't work because in an array context zsh is going to split on $IFS during the assignment itself, so you already have the wrong thing in $array before you even get as far as printing it. You need to use a scalar assignment: notyetarray=`print -N -- $list` array=(${(s:$'\0':)notyetarray}) Or (note the double quotes): array=( ${(ps:\0:)"$(print -rN -- $list)"} ) } Any way of doing this without much mess? The above is about as un-messy as it gets.