From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3820 invoked from network); 10 May 2006 09:22:56 -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=BAYES_00,FORGED_RCVD_HELO, HTML_MESSAGE 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; 10 May 2006 09:22:56 -0000 Received: (qmail 51815 invoked from network); 10 May 2006 09:22:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 May 2006 09:22:40 -0000 Received: (qmail 14529 invoked by alias); 10 May 2006 09:22:31 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10233 Received: (qmail 14518 invoked from network); 10 May 2006 09:22:31 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 May 2006 09:22:31 -0000 Received: (qmail 50661 invoked from network); 10 May 2006 09:22:31 -0000 Received: from smtp.eu.citrix.com (195.153.38.115) by a.mx.sunsite.dk with SMTP; 10 May 2006 09:22:30 -0000 Received: from lonpexchmx01.citrite.net ([10.30.224.191]) by SMTP.EU.CITRIX.COM with ESMTP; 10 May 2006 10:22:13 +0100 X-IronPort-AV: i="4.05,108,1146438000"; d="scan'208,217"; a="5078543:sNHT58289720" Received: from lonpexch01.citrite.net ([10.30.224.136]) by lonpexchmx01.citrite.net with Microsoft SMTPSVC(6.0.3790.1830); Wed, 10 May 2006 10:22:12 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C67413.384B2AFB" Subject: Parameter expansion flags question Date: Wed, 10 May 2006 10:22:12 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Parameter expansion flags question Thread-Index: AcZ0EzhN8LTv/NUXSdqKylXHm/HXgA== From: "John Cooper" To: X-OriginalArrivalTime: 10 May 2006 09:22:12.0901 (UTC) FILETIME=[38933550:01C67413] This is a multi-part message in MIME format. ------_=_NextPart_001_01C67413.384B2AFB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I've been writing a function to run a command, extract the first word of each line of the command's output and use that as a parameter to another command. The command's output looks like this: 1:/Citrix/Pres WI http://RA.eng.citrite.net/Citrix/Pres 4.5.5.1159 c:\inetpub\wwwroot\Citrix\Pres =20 1:/Citrix/Pres2 WI http://RA.eng.citrite.net/Citrix/Pres2 4.5.5.1159 c:\inetpub\wwwroot\Citrix\Pres2=20 After some trial-and-error I finally have the following function: SITEMGR=3Dc:/Program\ Files/Citrix/Web\ Interface/4.5/sitemgr.exe delsites() { for site in "${(f)$($SITEMGR -i)}" ; { sitepath=3D${${=3Dsite}[1]} [[ -n "$sitepath" ]] && $SITEMGR -r "WICurrent=3D$sitepath" } } I'm new to the zsh parameter expansion flags, but I've gathered the ${(f) will take the command's output a line at a time, and the = ${=3Dsite} will then split each line into words, allowing me to grab the first word of each line. Is there a better (or simpler!) way to do this? When the command has no output, the `for' loop is still executed once (seemingly because the command is within double-quotes) and is the reason for checking that the length of $sitepath is non-zero. Is there a way to avoid the loop being entered when the command has no output and avoid the need for this check? (btw, is there a good set of examples of using parameter expansion flags? The zsh guide seemed a bit sparse in this area) Thanks, --- John ------_=_NextPart_001_01C67413.384B2AFB Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Parameter expansion flags question

Ive been = writing a function to run a = command, extract the first word of each line of = the = commands output and use that as a parameter to = another command. The commands output looks like = this:

After some trial-and-error I finally have the following = function:

      SITEMGR=3Dc:/Program\ Files/Citrix/Web\ = Interface/4.5/sitemgr.exe

      delsites() {

          for site in "${(f)$($SITEMGR = -i)}" ; {

              sitepath=3D${${=3Dsite}[1]}

              [[ -n "$sitepath" ]] && $SITEMGR -r = "WICurrent=3D$sitepath"

          }

      }

Im new to = the = zsh = parameter expansion flags, but Ive gathered the ${(f) will take the = commands output a line at a time, and the = ${=3Dsite} will then split each line into words, allowing me to = grab the first word of each line.

Is = there a better (or simpler!) way to do this?  When the = command has no output, the `for loop is still executed once = (seemingly because the command is within = double-quotes) and is the reason for checking that the length = of $sitepath is non-zero. Is there a way to avoid = the loop being entered when the command has no output and avoid the need for = this check?

(btw, is there a good set of examples of using parameter = expansion flags? The zsh guide seemed a bit sparse in this = area)

Thanks,

    --- = John

------_=_NextPart_001_01C67413.384B2AFB--