Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: `cd .` in non-existent directory leads into weird corner case
On 2012-04-02 12:15:59 +0200, Mikael Magnusson wrote:
> On 2 April 2012 11:52, Richard Hartmann <richih.mailinglist@xxxxxxxxx> wrote:
> > On Tue, Mar 27, 2012 at 16:34, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxx> - 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)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author