Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
fewer forks
- X-seq: zsh-users 14172
- From: Scott Lipcon <slipcon@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: fewer forks
- Date: Mon, 25 May 2009 09:59:56 -0400
- 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=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author