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: Tue, 3 Apr 2012 12:16:37 +0200 [thread overview]
Message-ID: <CAHYJk3T+k3zEgm=1LYt0r=dz0WszFpBp9_PAw2fz76J__eLi_w@mail.gmail.com> (raw)
In-Reply-To: <20120403105748.6b16c3aa@pwslap01u.europe.root.pri>
On 3 April 2012 11:57, Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> On Mon, 2 Apr 2012 13:10:17 +0200
> Mikael Magnusson <mikachu@gmail.com> wrote:
>> One (semi-)realistic case I came up with, one shell sits in a
>> directory, someone else first moves the directory, then deletes it,
>> then the shell tries to 'cd ..'. In this case I would like it to end
>> up in the new parent directory as it does now [1], not the old
>> "$PWD:h". (with chasedots/-P) (and even if I did 'cd .' first for some
>> weird reason).
>
> Hmmm... when I read this before I concentrated on "as it does now" and
> skipped the "not the old $PWD:h". I don't see how that can work.
> You're saying we should use the physical directory to find its parent
> even though it doesn't exist any more.
>
> Are you saying you think the shell currently has some magic to do
> this? It seems to violate the laws of physics, unless we recorded
> the physical directory as a second PWD just on the off chance someone
> deletes the current one, which seems silly.
I don't know if this is something that works on all systems, but on
linux at least, it seems that the directory inode sticks around while
a process still has it, or any subdirectory of it, as its current
directory (or otherwise open i suppose). This means that it is still
possible to access the . and .. entries in it, and follow them via
chdir(), see the transcripts in my other mail where it even works from
a second shell going into the dir via 'cd /proc/$firstshell/cwd' and
then doing 'cd -P ..'.
If the system doesn't keep the '..' entry around, I'm not demanding
that cd -P .. should work as I described :).
--
Mikael Magnusson
next prev parent reply other threads:[~2012-04-03 10:16 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 [this message]
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
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='CAHYJk3T+k3zEgm=1LYt0r=dz0WszFpBp9_PAw2fz76J__eLi_w@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).