From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21131 invoked from network); 12 May 2006 11:03:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 May 2006 11:03:05 -0000 Received: (qmail 6778 invoked from network); 12 May 2006 11:02:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 May 2006 11:02:57 -0000 Received: (qmail 3271 invoked by alias); 12 May 2006 11:02:47 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10253 Received: (qmail 3261 invoked from network); 12 May 2006 11:02:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 May 2006 11:02:46 -0000 Received: (qmail 5474 invoked from network); 12 May 2006 11:02:46 -0000 Received: from smtp.eu.citrix.com (195.153.38.115) by a.mx.sunsite.dk with SMTP; 12 May 2006 11:02:44 -0000 Received: from lonpexchmx01.citrite.net ([10.30.224.191]) by SMTP.EU.CITRIX.COM with ESMTP; 12 May 2006 12:02:31 +0100 X-IronPort-AV: i="4.05,120,1146438000"; d="scan'208"; a="5112463:sNHT49222268" Received: from lonpexch01.citrite.net ([10.30.224.136]) by lonpexchmx01.citrite.net with Microsoft SMTPSVC(6.0.3790.1830); Fri, 12 May 2006 12:02:31 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Parameter expansion flags question Date: Fri, 12 May 2006 12:02:30 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Parameter expansion flags question Thread-Index: AcZ1GXNmz7MK2yRoTW2xDBg8JmO+gQAmSDUg From: "John Cooper" To: "Bart Schaefer" , X-OriginalArrivalTime: 12 May 2006 11:02:31.0474 (UTC) FILETIME=[90C01120:01C675B3] > Placement of the quotes is important: > for site in ${(f)"$($SITEMGR -i)":#} OK, changing the placement of the quotes to the above fixes it. There's just one thing I'm a little puzzled about - in the case where $SITEMGR produces no output, won't "$($SITEMGR -i)" be the empty string? If so, why is :# needed? It seems it will just replace an empty string with another empty string? Thanks, --- John -----Original Message----- From: Bart Schaefer [mailto:schaefer@brasslantern.com]=20 Sent: 11 May 2006 17:39 To: zsh-users@sunsite.dk Subject: Re: Parameter expansion flags question [skipping around a bit] On May 11, 10:59am, John Cooper wrote: } } One final thing - when I entered the "read" example into the shell as } stated I got syntax errors. These were resolved by using "do" and "done" } instead of braces - is this to be expected? Yeah, I messed up. I never use the form with the braces, but you did in your original "for" sample, so I tried to keep it with "while". I forgot that for "while" loops it only works when the first condition is [[ ... ]] or (( ... )). } Thanks for the detailed reply - it seems using "read" is the most } straightforward approach. However, in the interests of learning more } about expansions, I've been trying your suggestions and they don't seem } to work as expected. Oh, duh. I spaced that there were multiple lines of output from the $SITEMGR program. Obviously you need to process each line separately before applying the subscript. (This cold I'm coming down with must be affecting me worse than I thought.) } If I add the ":#pattern" operator to the original function, the "for" } loop is still executed once in the case where $SITEMGR produces no } output: } delsites4 () { } for site in "${(f)$($SITEMGR -i):#}" Placement of the quotes is important: for site in ${(f)"$($SITEMGR -i)":#} If it still happens, I think it's because of Cygwin line termination. Instead of an empty string when splitting with (f), you're getting a string having a single carriage-return character.