zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <Peter.Stephenson@csr.com>
Cc: zsh-users@zsh.org
Subject: Re: `cd .` in non-existent directory leads into weird corner case
Date: Mon, 2 Apr 2012 12:46:47 +0200	[thread overview]
Message-ID: <CAHYJk3S_jgi-s88ujo6_2Wpw0z2iEp1pybsc6KU5cj5Ej+A2Qg@mail.gmail.com> (raw)
In-Reply-To: <20120402113307.15ec97d2@pwslap01u.europe.root.pri>

On 2 April 2012 12:33, Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> On Mon, 2 Apr 2012 12:15:59 +0200
> Mikael Magnusson <mikachu@gmail.com> 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


  reply	other threads:[~2012-04-02 10:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-27  0:56 Richard Hartmann
2012-03-27  5:13 ` Daniel Shahaf
2012-03-27 14:34 ` Bart Schaefer
2012-03-27 15:25   ` Richard Hartmann
2012-04-02  9:52   ` Richard Hartmann
2012-04-02 10:12     ` Peter Stephenson
2012-04-02 10:56       ` Mikael Magnusson
2012-04-02 11:00         ` Peter Stephenson
2012-04-02 11:10           ` Mikael Magnusson
2012-04-02 11:39             ` Peter Stephenson
2012-04-03  9:51             ` Richard Hartmann
2012-04-03  9:57             ` Peter Stephenson
2012-04-03 10:16               ` Mikael Magnusson
2012-04-03 11:11                 ` Richard Hartmann
2012-04-03 14:06                 ` Bart Schaefer
2012-04-02 10:15     ` Mikael Magnusson
2012-04-02 10:33       ` Peter Stephenson
2012-04-02 10:46         ` Mikael Magnusson [this message]
2012-04-02 11:07       ` Vincent Lefevre
2012-04-02 12:59       ` Richard Hartmann
2012-04-03  4:04         ` Jun T.
2012-04-03 14:43           ` Vincent Lefevre
2012-04-04 17:03             ` Jun T.
2012-04-05 14:20               ` Vincent Lefevre
2012-04-05 16:17                 ` Jun T.
2012-04-15  1:17                   ` Vincent Lefevre
2012-04-15 18:07                     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3S_jgi-s88ujo6_2Wpw0z2iEp1pybsc6KU5cj5Ej+A2Qg@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=Peter.Stephenson@csr.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).