From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25218 invoked from network); 28 Sep 1999 16:43:12 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Sep 1999 16:43:12 -0000 Received: (qmail 25776 invoked by alias); 28 Sep 1999 16:43:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8087 Received: (qmail 25769 invoked from network); 28 Sep 1999 16:42:59 -0000 From: "Bart Schaefer" Message-Id: <990928164248.ZM21457@candle.brasslantern.com> Date: Tue, 28 Sep 1999 16:42:47 +0000 In-Reply-To: <9909281007.AA22813@ibmth.df.unipi.it> Comments: In reply to Peter Stephenson "Re: cd, pwd and symlinks" (Sep 28, 12:07pm) References: <9909281007.AA22813@ibmth.df.unipi.it> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Re: cd, pwd and symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 28, 12:07pm, Peter Stephenson wrote: } Subject: Re: cd, pwd and symlinks } } "Stefan Monnier" wrote: } >That's indeed what I'm complaining about. The default behavior is very } >non-unixish which is surprising for a unix-only tool. } } In that case, ksh is non-UNIXish too, since it has this logical path } feature on by default. (Plus it's still able to change up from a } no-longer-existent directory, which zsh isn't after the last round of } cd changes, but we had this discussion at length some months ago.) Hm. I thought "cd .." was only supposed to fail if chasedots was set. "cd ." or "cd ../$PWD:t" are supposed to fail if the destination doesn't exist. But this is a side-effect of "cd .." turning into "cd $PWD/.." plus the rule that "cd /some/missing/directory/.." is supposed to fail, isn't it. Argh. } > But how hard would it be to have `pwd' do a stat("$PWD") and stat(".") } > and compare the inode to make sure the current $PWD is still valid ? } } It does seem that this could be improved. I can't decide whether I object to this ... but perhaps it should at least not happen when ksh emulation is in effect? } This isn't perfect, since unless you run pwd, the shell doesn't know if the } path to the current directory became invalid and a cd can still fail, but } at least it gives you a natural way of fixing it. A bit confusing, though, isn't it? zsh% cd /tmp/test zsh% cd subdir zsh: No such file or directory: subdir zsh% pwd /tmp/renamed zsh% cd subdir zsh% If there were much elapsed time at all between the first two cd's, the poor user might not remember where he was before the pwd, and would have no idea what was going on. And finally, `dirs` still outputs the previous value of PWD. } 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 sure other people will have completely different ideas, they always do } with directories. Indeed. I may have a look at this later today if I get a chance. I'm thinking that (a) pwd should do something more like cd_new_pwd() (but not including calling chpwd) if it can't stat(pwd), and (b) cd should try harder, perhaps implicitly behaving as if chasedots, if it can't stat(pwd). -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com