From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11823 invoked from network); 23 Jun 2004 16:54:48 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 23 Jun 2004 16:54:48 -0000 Received: (qmail 21156 invoked from network); 23 Jun 2004 16:53:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 23 Jun 2004 16:53:33 -0000 Received: (qmail 9300 invoked by alias); 23 Jun 2004 16:53:15 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7597 Received: (qmail 9290 invoked from network); 23 Jun 2004 16:53:15 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 23 Jun 2004 16:53:12 -0000 Received: (qmail 20290 invoked from network); 23 Jun 2004 16:53:11 -0000 Received: from mail.hummerdns.net (HELO secure3.hummerdns.net) (207.44.152.5) by a.mx.sunsite.dk with SMTP; 23 Jun 2004 16:53:10 -0000 Received: from diavolo.exile.net (S0106000d88e212e5.gv.shawcable.net [24.68.20.99]) (authenticated (0 bits)) by secure3.hummerdns.net (8.11.6/8.11.6) with ESMTP id i5NGslI04584 for ; Wed, 23 Jun 2004 11:54:47 -0500 Received: by diavolo.exile.net (Postfix, from userid 1000) id 5055D40AD; Wed, 23 Jun 2004 09:55:20 -0700 (PDT) Date: Wed, 23 Jun 2004 09:55:20 -0700 From: Sami Samhuri To: zsh-users@sunsite.dk Subject: Re: How to clean up path most efficiently? Message-ID: <20040623165520.GG13612@no-eff-eks.com> Mail-Followup-To: zsh-users@sunsite.dk References: <200406230856.i5N8ucoF002908@news01.csr.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kjpMrWxdCilgNbo1" Content-Disposition: inline In-Reply-To: <200406230856.i5N8ucoF002908@news01.csr.com> User-Agent: Mutt/1.5.6i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 --kjpMrWxdCilgNbo1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * It was Wed, Jun 23, 2004 at 09:56:38AM +0100 when Peter Stephenson said: > Timothy Luoma wrote: > > > It should be as simple as: > > >=20 > > > path=3D($^path(N)) > >=20 > > Does that go through the current $PATH and delete all the folders that > > aren't listed in there? >=20 > I should probably have explained in more detail at the time. >=20 > The ^ indicates that anything outside the array should be expanded with > each element, so the expression becomes something like: >=20 > path=3D(/usr/local/bin(N) //usr/nonexistent/bin(N) /usr/bin(N) /bin(N)) >=20 > 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: >=20 > path=3D(/usr/local/bin /usr/bin bin) >=20 > which then gets assigned back to path. This automatically appears in > PATH as >=20 > PATH=3D/usr/local/bin:/usr/bin:/bin This is great. Thanks for the explanation! For zsh newbies some of the syntax seems cryptic at first. --=20 Sami Samhuri --kjpMrWxdCilgNbo1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFA2bX4ukGyBH1UC2MRAts0AJ9AsJrfiDAida946iEW2dVYQIU7vACfXbJM QmsGy1frncnhK56WHrmVmsY= =G7pR -----END PGP SIGNATURE----- --kjpMrWxdCilgNbo1--