zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Richard Hartmann <richih.mailinglist@gmail.com>,
	Bart Schaefer <schaefer@brasslantern.com>,
	zsh-users@zsh.org
Subject: Re: `cd .` in non-existent directory leads into weird corner case
Date: Mon, 2 Apr 2012 13:07:46 +0200	[thread overview]
Message-ID: <20120402110746.GD4925@xvii.vinc17.org> (raw)
In-Reply-To: <CAHYJk3Q+xuvMH7RVDif8ExhbrRVnapUwU0cMeTi1+OsaFUR5Yw@mail.gmail.com>

On 2012-04-02 12:15:59 +0200, Mikael Magnusson wrote:
> On 2 April 2012 11:52, Richard Hartmann <richih.mailinglist@gmail.com> wrote:
> > On Tue, Mar 27, 2012 at 16:34, Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> >> However, I've always been a little puzzled about the decision to set
> >> $PWD to "." in this case.  Bash remembers the relative location:
> >
> > Just to make sure this does not get lost, do we agree that not
> > changing $PWD to a literal dot would make sense? Escalating the ENOENT
> > to the user is probably the best approach.
> 
> Weird, when I try making a directory and remove it, I can still cd ..
> to the parent... I can even cd into the dir with another shell (via
> /proc/$$/cwd), and cd .. to the correct parent dir from that other
> shell.

This seems to depend on the file system. The following script

tst()
{
  base=`pwd`

  echo "Test 1"
  mkdir dir
  cd dir
  rmdir ../dir
  pwd
  cd .
  pwd
  cd ..
  pwd

  cd "$base"

  echo "Test 2"
  mkdir dir
  cd dir
  rmdir ../dir
  pwd
  cd ..
  pwd
}

tst

under NFS sometimes gives with zsh 4.3.12:

Test 1
/home/vlefevre/dir
tst:cd:9: no such file or directory: .
/home/vlefevre/dir
tst:cd:11: no such file or directory: ..
/home/vlefevre/dir
Test 2
/home/vlefevre/dir
tst:cd:21: no such file or directory: ..
/home/vlefevre/dir

and sometimes:

Test 1
/home/vlefevre/dir
tst:cd:9: no such file or directory: .
/home/vlefevre/dir
tst:cd:11: no such file or directory: ..
/home/vlefevre/dir
Test 2
/home/vlefevre/dir
/home/vlefevre

and sometimes:

Test 1
/home/vlefevre/dir
.
/home/vlefevre
Test 2
/home/vlefevre/dir
tst:cd:21: no such file or directory: ..
/home/vlefevre/dir

>From /tmp, I always get:

Test 1
/tmp/dir
.
/tmp
Test 2
/tmp/dir
/tmp

With sh (dash):

Test 1
/home/vlefevre/dir
cd: 26: can't cd to .
/home/vlefevre/dir
/home/vlefevre
Test 2
/home/vlefevre/dir
/home/vlefevre

and

Test 1
/tmp/dir
cd: 26: can't cd to .
/tmp/dir
/tmp
Test 2
/tmp/dir
/tmp

respectively.

With zsh in ksh emulation:

Test 1
/home/vlefevre/dir
tst:cd:9: no such file or directory: .
/home/vlefevre/dir
tst:cd:11: no such file or directory: ..
/home/vlefevre/dir
Test 2
/home/vlefevre/dir
tst:cd:21: no such file or directory: ..
/home/vlefevre/dir

or

Test 1
/home/vlefevre/dir
.
.
Test 2
/home/vlefevre/dir
/home/vlefevre

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


  parent reply	other threads:[~2012-04-02 11:07 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
2012-04-02 11:07       ` Vincent Lefevre [this message]
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=20120402110746.GD4925@xvii.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=mikachu@gmail.com \
    --cc=richih.mailinglist@gmail.com \
    --cc=schaefer@brasslantern.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).