From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25740 invoked from network); 28 Sep 1999 17:43:08 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Sep 1999 17:43:08 -0000 Received: (qmail 1411 invoked by alias); 28 Sep 1999 17:42:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8088 Received: (qmail 1404 invoked from network); 28 Sep 1999 17:42:58 -0000 Subject: Re: cd, pwd and symlinks In-Reply-To: <990928164248.ZM21457@candle.brasslantern.com> from Bart Schaefer at "Sep 28, 1999 4:42:47 pm" To: schaefer@candle.brasslantern.com (Bart Schaefer) Date: Tue, 28 Sep 1999 18:42:46 +0100 (BST) Cc: zsh-workers@sunsite.auc.dk X-Mailer: ELM [version 2.4ME+ PL48 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: From: Zefram Bart Schaefer wrote: >On Sep 28, 12:07pm, Peter Stephenson wrote: >} There's some reason why the code was changed >} to do all changes with absolute path --- maybe to simplify it, hur hur. > >As far as I can tell, this is something Zefram changed between 3.1.2 and >3.1.3, for which no patch was ever posted. I'm pretty sure it's not. That's one of the areas of the shell that I studiously avoided changing. If I'd designed the shell from scratch, it would match the underlying OS behaviour, and consequently $PWD wouldn't exist, or at least not in the form we have it. $PWD is really an abomination, giving the impression of an absolute directory structure, which in fact doesn't exist. Given that we have to support it, there are basically two sensible ways for it to work: 1. cd maps directly onto chdir(), doing everything the way the filesystem says. $PWD has no direct effect -- it is equivalent to $(pwd), recalculated every time it is referenced. It always searches for a valid absolute pathname referring to the current directory. The user must accept that it will sometimes fail (yielding "."), and that the pathname returned will not necessarily remain valid, but it will always be valid at the moment it is evaluated. 2. $PWD is the shell's canonical idea of its current directory. cd with a relative pathname does text substitution using $PWD, and then does a chdir() to the resulting absolute pathname. pwd just gives $PWD, and has an option to do a /bin/pwd-style search instead. The user must accept that the current directory may not be accessible under the name in $PWD, and that relative filenames in a cd command have completely different semantics from relative filenames everywhere else. Until 3.1.6, we had a pretty consistent 2. Now we have a mixture of the two styles, which isn't working, and making it more complicated isn't going to help. Let's just have the two ways of working, with an option to switch between them. -zefram