Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to clean up path most efficiently?

* It was Wed, Jun 23, 2004 at 09:56:38AM +0100 when Peter Stephenson said:
> Timothy Luoma wrote:
> > > It should be as simple as:
> > > 
> > > path=($^path(N))
> > 
> > Does that go through the current $PATH and delete all the folders that
> > aren't listed in there?
> I should probably have explained in more detail at the time.
> The ^ indicates that anything outside the array should be expanded with
> each element, so the expression becomes something like:
> path=(/usr/local/bin(N) //usr/nonexistent/bin(N) /usr/bin(N) /bin(N))
> The presence of the glob qualifier (N) turns on globbing even though
> there are no patterns present (historically, it didn't always do that).
> The shell then goes through it turning any name which doesn't exist in the
> filesystem into a null string, and passing the rest through, so it
> becomes something like:
> path=(/usr/local/bin /usr/bin bin)
> which then gets assigned back to path.  This automatically appears in
> PATH as
> PATH=/usr/local/bin:/usr/bin:/bin

This is great. Thanks for the explanation! For zsh newbies some of the
syntax seems cryptic at first.

Sami Samhuri

Attachment: pgpWQ3W1I37w6.pgp
Description: PGP signature

Messages sorted by: Reverse Date, Date, Thread, Author