From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10053 invoked from network); 30 Dec 2005 12:53:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Dec 2005 12:53:10 -0000 Received: (qmail 53639 invoked from network); 30 Dec 2005 12:53:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Dec 2005 12:53:03 -0000 Received: (qmail 24321 invoked by alias); 30 Dec 2005 12:53:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22111 Received: (qmail 24311 invoked from network); 30 Dec 2005 12:52:59 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Dec 2005 12:52:59 -0000 Received: (qmail 53349 invoked from network); 30 Dec 2005 12:52:59 -0000 Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by a.mx.sunsite.dk with SMTP; 30 Dec 2005 12:52:57 -0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EsJkV-0006qu-2C for zsh-workers@sunsite.dk; Fri, 30 Dec 2005 13:52:47 +0100 Received: from haugen.visit.se ([212.214.112.43]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Dec 2005 13:52:47 +0100 Received: from qha by haugen.visit.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Dec 2005 13:52:47 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@sunsite.dk From: Ulrik Haugen Subject: Re: BUG: cd '' doesn't produce an error Date: Fri, 30 Dec 2005 13:52:42 +0100 Message-ID: <877j9mycf9.fsf@haugen.visit.se> References: <87zmmvxl3g.fsf@haugen.visit.se> <20051221102159.44d9f5ca.pws@csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: haugen.visit.se User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:rHibJZME1oxTnA9/QJuM2i7V5tk= Sender: news Hello! Peter Stephenson wrote: > Ulrik Haugen wrote: >> I recently discovered that zsh (versions 4.2.5 and 4.3.0-dev-1) >> doesn't produce an error when i attempt to "cd ''" (in version 3.0.8 I >> get the error i expected). Please let me know if you'd like me to test >> any other versions. > It's certainly strange, although it's not wholly illogical with $cdpath: as > the empty string is not an absolute directory nor begins with . or .., the > shell looks through $cdpath for the first directory for which the > concatenation with the empty string exists, which is usually just the first > directory in $cdpath. This is almost useful... It's easy to add an error > but I'm not quite sure at what stage the behaviour actually is an error in > this case: it's a correct, if unexpected, interpretation of the cdpath > rules. Sorry for taking so long to reply, but I haven't had the time to look into properly this until now. I'm still not quite satisfied with this behaviour for a couple of reasons: In my tests I had not set cdpath, so I don't see why the shell should go through any cdpath rules. If I try % cd /tmp; CDPATH=/usr cd '' I still wind up in /tmp, so it doesn't seem to have that much to do with cdpath to me. If I had ended ended up in /usr, I'm not really sure I'd like that either (although someone who uses cdpath is probably a better judge). My intuitive expectation was that cd would successively cd to each component of cdpath, try to cd to the argument given and be satisfied at the first successful cd (though obviously just appending "/$arg" to each component in cdpath and successively trying to cd to that is cheaper). The reason I take the time to argue about this is that I often want to determine the absolute path my scripts are called from in this fashion: scriptdir=`dirname "$0"` scriptdir=`cd "$scriptdir"&& pwd` More than once I've decided I'm not happy with whatever variable name has had the role of scriptdir and only changed the occurences at the beginnings of lines. Right now zsh silently ignores my error and I'll get the callers present working directory in the whatever new name I've chosen for scriptdir. Admittedly I'd get a faulty value if zsh complained to, but at least I'd get some indication of my mistake.