Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: `cd .` in non-existent directory leads into weird corner case

On 2 April 2012 13:00, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Mon, 2 Apr 2012 12:56:55 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> >> 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.
>> >
>> > Sounds OK.  Silently failing and changing the directory reported doesn't
>> > really do a lot of good to anyone.
>> Can we keep the current behaviour for cd -P?
> I think that only those cases that currently give up and silently revert
> to "." as the current directory would be affected, so anything that
> already did something sensible would still do that.  Certainly that's
> what we should be aiming for.

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).

Mikael Magnusson

{13:08:58|~}% mkcd foo
{13:09:04|~/foo}% mv ~/foo ~/tmp # ~/tmp already exists
{13:09:07|~/foo}% rmdir ~/tmp/foo
{13:09:09|~/foo}% cd ..

Messages sorted by: Reverse Date, Date, Thread, Author