From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7980 invoked from network); 25 May 2009 14:00:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 25 May 2009 14:00:40 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 28093 invoked from network); 25 May 2009 14:00:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 May 2009 14:00:23 -0000 Received: (qmail 3685 invoked by alias); 25 May 2009 14:00:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14172 Received: (qmail 3655 invoked from network); 25 May 2009 14:00:01 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 25 May 2009 14:00:01 -0000 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.30]) by bifrost.dotsrc.org (Postfix) with ESMTP id 397A5801E289 for ; Mon, 25 May 2009 15:59:57 +0200 (CEST) Received: by yw-out-2324.google.com with SMTP id 3so1955721ywj.81 for ; Mon, 25 May 2009 06:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=vOQ6E5o1N6iAoE3Xm+fNvtYfxbICQCN1jvA/wRvsJmk=; b=fdLfqGGy+IPmlTMneqjVjsCPDh7BBAzWh2YVdddlzCqHZSgf0P1jupYZL/1tV+N7Ek u2pE9W0PhTzKAI6XMn9IAJPakUTyNYD2buD3MQ+QVjxGPVkhPZHyQi+9RhDga0EqSkly 7gAQU7t+WPbU+H+5Qd6l1Qq9K0uw5haXpPOo4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=EnAlVA79XBGr5S68Btq+YerTIEJXjAS01URqz3pCs5RaoIGDilVr/61vy3Hok1nYe2 W0VmL1HFU05X6LT8Je1IqRsqMx1/4380NM0Kz/Ix0Xkj3SU2h+WnNvYeLXKBXkYBvTY2 upS034Jd7c8avdOAP5FDsJKoGZAtFdp//QasA= MIME-Version: 1.0 Received: by 10.90.67.15 with SMTP id p15mr6348778aga.22.1243259996860; Mon, 25 May 2009 06:59:56 -0700 (PDT) Date: Mon, 25 May 2009 09:59:56 -0400 Message-ID: <580cd3b30905250659y3efb6099n98b97c4e104c900f@mail.gmail.com> Subject: fewer forks From: Scott Lipcon To: zsh-users@sunsite.dk Content-Type: multipart/alternative; boundary=0016367fba0c79f174046abd067e X-Virus-Scanned: ClamAV 0.94.2/9390/Mon May 25 14:49:36 2009 on bifrost X-Virus-Status: Clean --0016367fba0c79f174046abd067e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I have a couple of shell functions that I use to manipulate my environment and I'm looking to see if these can be done in a more "zsh way", specifically with fewer forks to external programs. 1) look for environment variables matching a pattern. I have a number of environment variables that all end in ROOT,and I need to add each $FOOROOT/bin to my path, $FOOROOT/lib to my LD_LIBRARY_PATH, etc. Currently I have functions like: function setLDPath { ld_library_path=( $base_ld_path ) for dir in `=env | =grep ROOT | =grep -v 'CVSROOT' | =cut -f1 -d=`; do ld_library_path=( $(eval "echo \$$dir/lib") $ld_library_path ) done } but thats a lot of external processes (env, grep, grep, cut, echo) to do something that seems like it should be simple. 2) grep for a pattern in a file. The project i work on has a csh script to set some variables (specifically, the $FOOROOT variables, above. Currently I'm doing: for root in `=grep '^setenv .*ROOT ' $REQS | =cut -f2 -d' '`; do ... done which pulls the name of the environment variable out of the file ($REQS) and then I have another grep piped to sed and tr to get (and slightly transform) the value. Thanks, Scott --0016367fba0c79f174046abd067e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I have a couple of shell functions that I use to manipulate my environment = and I'm looking to see if these can be done in a more "zsh way&quo= t;, specifically with fewer forks to external programs.

1)=A0 look f= or environment variables matching a pattern.=A0=A0 I have a number of envir= onment variables that all end in ROOT,and I need to add each $FOOROOT/bin t= o my path, $FOOROOT/lib to my LD_LIBRARY_PATH, etc.=A0=A0 Currently I have = functions like:


function setLDPath {
=A0=A0=A0 ld_library_path=3D( $base_ld_path= )

=A0=A0=A0 for dir in `=3Denv | =3Dgrep ROOT | =3Dgrep -v 'CVS= ROOT' | =3Dcut -f1 -d=3D`; do
=A0=A0=A0=A0=A0=A0=A0 ld_library_path= =3D( $(eval "echo \$$dir/lib") $ld_library_path )
=A0=A0=A0 done
}

but thats a lot of external processes (env, grep= , grep, cut, echo) to do something that seems like it should be simple.
=
2) grep for a pattern in a file.=A0 The project i work on has a csh scr= ipt to set some variables (specifically, the $FOOROOT variables, above.=A0 = Currently I'm doing:

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 for root in `=3Dgrep '^setenv .*R= OOT ' $REQS | =3Dcut -f2 -d' '`; do
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ...
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = done

which pulls the name of the environment variable out of the fil= e ($REQS) and then I have another grep piped to sed and tr to get (and slig= htly transform) the value.

Thanks,
Scott


--0016367fba0c79f174046abd067e--