From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23682 invoked by alias); 2 Apr 2012 10:46:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16949 Received: (qmail 24690 invoked from network); 2 Apr 2012 10:46:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.160.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=srMQAJAmQnoo/FIq2P7iOdvIOnImpBWrCyCBZm4QDOc=; b=Nremxs+KRp3S+MeJb87zSn94TT+lwsprLe1EZWy/9W4AI+Xfj7APIKkF6BZ73gWIU4 bEulfk/uCUXn3PLe572lM4bULl+FkBT1h0grqYD7YzW7jb0/vaWcLuigZuxnGRcUShe6 c/m0DMnhkfM3zccDpVLyWjZ/CPc00JOrBcdg5guj3SILeRnUJxoXjFNpD3OfALNJkb1k GpzehJwRdQmtRUpY/CiLFCSBVCtji7ut2wA6od+pOmO0NXPgWBNhS8CC8EdxbCEWxG8D Y3o74FwEyzx6VwSurOA3jWgLF1Apd5aExqxHTmVM7bwqKWkD0Z7C2RR59+Hqi30zwFsr ekoA== MIME-Version: 1.0 In-Reply-To: <20120402113307.15ec97d2@pwslap01u.europe.root.pri> References: <120327073414.ZM6783@torch.brasslantern.com> <20120402113307.15ec97d2@pwslap01u.europe.root.pri> Date: Mon, 2 Apr 2012 12:46:47 +0200 Message-ID: Subject: Re: `cd .` in non-existent directory leads into weird corner case From: Mikael Magnusson To: Peter Stephenson Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 2 April 2012 12:33, Peter Stephenson wrote: > On Mon, 2 Apr 2012 12:15:59 +0200 > Mikael Magnusson wrote: >> Weird, when I try making a directory and remove it, I can still cd .. >> to the parent... > > That's not weird; the shell remembers PWD because by default it changes > directory logically rather than physically, i.e. retaining symbolic > links in the path, so it changes to the parent directory by what > amounts to 'cd $PWD:h'. How does this explain that it works from the other shell that never knew what $PWD was? I'm sticking with my theory that the directory exists until we leave it :). I called it weird because obviously it doesn't work for richih, as one can see in his transcript. > What you get with CHASE_LINKS or cd -P is another matter, since the > ability to take account of symbolic links means the whole logic is > rather baroque, but I'd vaguely expect it either to fail or fail to > resolve the physical directory and default to trimming PWD. (What it > does and what it should do are again not necessarily identical.) Ah, and I do have both CHASE_LINKS and CHASE_DOTS set, which explains it. When I unset them, zsh indeed stays in mysterious '.' land forever. With them set, it properly follows the physical .. entries back to the parent directory. [so the first part has chase_* set] ~% mkcd foo ~/foo% rmdir ~+ ~/foo% cd . .% cd .. ~% mkcd foo/bar ~/foo/bar% rmdir ~+ ~+(:h) ~/foo/bar% zsh -f .% pwd . .% cd .. .% pwd . .% cd .. .% pwd . .% cd .. .% pwd . .% cd -P .. .% cd -P .. ~% -- Mikael Magnusson