From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29224 invoked from network); 14 Sep 2004 17:18:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Sep 2004 17:18:08 -0000 Received: (qmail 83386 invoked from network); 14 Sep 2004 17:18:01 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Sep 2004 17:18:01 -0000 Received: (qmail 23658 invoked by alias); 14 Sep 2004 17:17:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7989 Received: (qmail 23625 invoked from network); 14 Sep 2004 17:17:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 14 Sep 2004 17:17:15 -0000 Received: (qmail 82133 invoked from network); 14 Sep 2004 17:17:15 -0000 Received: from ns9.hostinglmi.net (213.194.149.146) by a.mx.sunsite.dk with SMTP; 14 Sep 2004 17:17:13 -0000 Received: from 212.red-80-35-44.pooles.rima-tde.net ([80.35.44.212] helo=dervishd.net) by ns9.hostinglmi.net with esmtpa (Exim 4.42) id 1C7Gvb-0005VT-LP; Tue, 14 Sep 2004 19:17:16 +0200 Date: Tue, 14 Sep 2004 19:19:17 +0200 From: DervishD To: Tero Niemela Cc: zsh-users@sunsite.dk Subject: Re: Two simple questions Message-ID: <20040914171917.GA592@DervishD> Mail-Followup-To: Tero Niemela , zsh-users@sunsite.dk References: <20040913211024.GA31504@DervishD> <20040914163758.80589.qmail@web61310.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040914163758.80589.qmail@web61310.mail.yahoo.com> User-Agent: Mutt/1.4.2.1i Organization: DervishD X-PopBeforeSMTPSenders: raul@dervishd.net X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns9.hostinglmi.net X-AntiAbuse: Original Domain - sunsite.dk X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dervishd.net X-Source: X-Source-Args: X-Source-Dir: 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 Hi Tero :) * Tero Niemela dixit: > > > 0) I'm seeing dirs like /bin /bin/ and even /bin// > > in > > > my PATH. > > You're looking > > for something like (EXTENDED_GLOB must be set, for > > the '#'): > > path=(${(qq)${path//\/##/\/}%/}) > > > > This converts multiple slashes to just one, and > > then removes the > > last one. The '(qq)' part is needed just in case > > 'path' has elements with spaces in it. > In some cases (Cygwin) it indeed does have spaces. > However, your solution seems not to be optiomal: > ~> export PATH=/bin:/usr/bin:/bin//:/bin/ > ~> which ls > /bin/ls > ~> path=(${(qq)${path//\/##/\/}%/}) > ~> echo $PATH > '/bin':'/usr/bin':'/bin/' > ~> which ls > ls not found > zsh: exit 1 > ~> The slash removing works here. It seems you don't have 'EXTENDED_GLOB' set. You must in order the recipe to work ;) And yes, the quoting completely screws the functioning of the PATH, and the worst thing is that... it is not needed O:) Array elements are separate words, so you just need to do this: setopt EXTENDED_GLOB path=(${${path//\/##/\/}%/}) unsetopt EXTENDED_GLOB The setopt is only needed, obviously, if you don't have EXTENDED_GLOB set, which you don't seem to have. Hope this helps :) At least it works for me with your example above (and adding a directory with spaces in it. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/