From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10676 invoked from network); 15 Sep 2004 10:31:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Sep 2004 10:31:51 -0000 Received: (qmail 52151 invoked from network); 15 Sep 2004 10:31:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Sep 2004 10:31:44 -0000 Received: (qmail 15402 invoked by alias); 15 Sep 2004 10:31:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7998 Received: (qmail 15387 invoked from network); 15 Sep 2004 10:30:59 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Sep 2004 10:30:59 -0000 Received: (qmail 50605 invoked from network); 15 Sep 2004 10:30:00 -0000 Received: from mail1.messagelabs.com (212.125.75.4) by a.mx.sunsite.dk with SMTP; 15 Sep 2004 10:29:58 -0000 X-VirusChecked: Checked X-Env-Sender: Stephane.Chazelas@morse.com X-Msg-Ref: server-4.tower-1.messagelabs.com!1095244196!20233708 X-StarScan-Version: 5.2.10; banners=-,-,- X-Originating-IP: [195.152.231.104] Received: (qmail 31113 invoked from network); 15 Sep 2004 10:29:56 -0000 Received: from unknown (HELO GIS-MAIL-01.morse.corp.wan) (195.152.231.104) by server-4.tower-1.messagelabs.com with SMTP; 15 Sep 2004 10:29:56 -0000 Received: from frhdtmp102861 (frhdtmp102861.morse.corp.wan [10.25.10.16]) by GIS-MAIL-01.morse.corp.wan with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id S9P8M68P; Wed, 15 Sep 2004 11:29:56 +0100 Date: Wed, 15 Sep 2004 11:29:52 +0100 From: Stephane Chazelas To: zsh-users@sunsite.dk Cc: Tero Niemela Subject: Re: Two simple questions Message-ID: <20040915102951.GB2228@frhdtmp102861.morse.corp.wan> Mail-Followup-To: zsh-users@sunsite.dk, Tero Niemela References: <20040914190916.GA974@DervishD> <20040915051128.66457.qmail@web61305.mail.yahoo.com> <20040915083655.GA1180@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20040915083655.GA1180@DervishD> 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=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 On Wed, Sep 15, 2004 at 10:36:56AM +0200, DervishD wrote: [...] > > > > path=($^path(N)) > > > > manpath=($^manpath(N)) [...] > Very clever! :) The '^' makes the '(N)' glob qualifier to be > added to each element of the array :)) Thanks a lot for the > explanation, is a very clever way of removing non-existent dirs from > a list (well, an array in this case). [...] All the given solutions seem to forget about one thing about $PATH. An empty element in it means "current directory". $path instead of "$path[@]" removes the empty components in it. That doesn't apply to $^path, though, but to the other solutions. $ echo $PATH /usr/xpg4/bin:/usr/bin:/usr/local/bin: $ print -rl $path /usr/xpg4/bin /usr/bin /usr/local/bin $ print -rl "$path[@]" /usr/xpg4/bin /usr/bin /usr/local/bin $ print -rl ${^path}(N) /usr/xpg4/bin /usr/bin /usr/local/bin $ You can change "" to "." with ${path/(#s)(#e)/.} but that's slightly different. $ PATH=/::/bin://bin/ $ print -rl ${(u)${${path/(#s)(#e)/.}//\/##/\/}/(#b)(?)\/(#e)/$match} / . /bin $ (note that ${path/%\//} changes "/" into "". -- Stephane