Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: `cd .` in non-existent directory leads into weird corner case
- X-seq: zsh-users 16949
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: `cd .` in non-existent directory leads into weird corner case
- Date: Mon, 2 Apr 2012 12:46:47 +0200
- Cc: zsh-users@xxxxxxx
- 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==
- In-reply-to: <20120402113307.15ec97d2@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAD77+gT4LXRyTL8V1UZrNfCohyJ9peTNdfZ=G7Q-sJcDnyNE8Q@mail.gmail.com> <120327073414.ZM6783@torch.brasslantern.com> <CAD77+gSn9zrTHDMj=zi_Y5M6b86pOizkUin8zVVEAU1aTfuKfw@mail.gmail.com> <CAHYJk3Q+xuvMH7RVDif8ExhbrRVnapUwU0cMeTi1+OsaFUR5Yw@mail.gmail.com> <20120402113307.15ec97d2@pwslap01u.europe.root.pri>
On 2 April 2012 12:33, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Mon, 2 Apr 2012 12:15:59 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author