zsh-users
 help / color / mirror / code / Atom feed
From: Danny Dulai <nirva@ishiboo.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@sunsite.auc.dk
Subject: Re: Setting paths with ~'s in values.
Date: Mon, 22 Feb 1999 17:20:07 -0500	[thread overview]
Message-ID: <19990222172007.61479@bleep.ishiboo.com> (raw)
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


  parent reply	other threads:[~1999-02-22 22:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-12 20:17 Larry P . Schrof
1999-02-12 22:05 ` Bart Schaefer
1999-02-12 22:29   ` Bart Schaefer
1999-02-22 22:20   ` Danny Dulai [this message]
1999-02-23  4:58     ` Bart Schaefer
1999-02-23  8:39       ` Danny Dulai
1999-02-24  5:07         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990222172007.61479@bleep.ishiboo.com \
    --to=nirva@ishiboo.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).