From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29678 invoked from network); 22 Feb 1999 22:21:13 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Feb 1999 22:21:13 -0000 Received: (qmail 17356 invoked by alias); 22 Feb 1999 22:20:17 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2174 Received: (qmail 17345 invoked from network); 22 Feb 1999 22:20:13 -0000 Message-ID: <19990222172007.61479@bleep.ishiboo.com> Date: Mon, 22 Feb 1999 17:20:07 -0500 From: Danny Dulai To: Bart Schaefer Cc: zsh-users@sunsite.auc.dk Subject: Re: Setting paths with ~'s in values. References: <199902122018.PAA29284@po_box.cig.mot.com> <990212140558.ZM11520@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.88 In-Reply-To: <990212140558.ZM11520@candle.brasslantern.com>; from Bart Schaefer on Fri, Feb 12, 1999 at 02:05:58PM -0800 Quoting Bart Schaefer (schaefer@brasslantern.com): > A direct translation would thus be: > > for t_path in $(<${HOME}/.zpaths) > do > if > [[ -d $t_path ]] > then > eval path=\( $path $t_path \) > fi > done This didnt seem to add the paths with ~ in them because the ~ didnt get expanded in the test for existence. i had to do an eval before the if, so the -d would work: for t_path in $(<${HOME}/.zpaths) do eval t_path=$t_path if [ -d $t_path ]; then path=( $path $t_path ) fi done This works perfectly for me. > and you don't need the extra step of removing the leading colon. But > there's a better, faster, smarter way to do the same thing: > > eval path=\( ${^$(<${HOME}/.zpaths)}'(|)(/)' \) > > Here, the ${^...} takes the place of the "for" loop, the (/) tests a > glob pattern to see if it refers to a directory, and the (|) turns each > of the lines from .zpaths into an equivalent glob pattern so that (/) > test is applied. The quotes and backslashes just make sure that the > globbing and array assignment steps are delayed until the "eval" runs. Aftertmuch of fiddling with this, I found it works if I have NULL_GLOB set. eval path=\( ${^$(<${HOME}/.zpaths)}'(|)(/N)' \) works even if you don't have that option st (good for using it in .zshenv if you set optoin in .zshrc). -- ___________________________________________________________________________ Danny Dulai Feet. Pumice. Lotion. http://www.ishiboo.com/~nirva/ nirva@ishiboo.com