zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Richard Hartmann <richih.mailinglist@gmail.com>
Cc: zsh-users@zsh.org
Subject: Re: `cd .` in non-existent directory leads into weird corner case
Date: Tue, 27 Mar 2012 07:13:43 +0200	[thread overview]
Message-ID: <20120327051343.GB27197@daniel3.local> (raw)
In-Reply-To: <CAD77+gT4LXRyTL8V1UZrNfCohyJ9peTNdfZ=G7Q-sJcDnyNE8Q@mail.gmail.com>

Richard Hartmann wrote on Tue, Mar 27, 2012 at 02:56:23 +0200:
> Hi all,
> 
> maybe I am misunderstanding zsh's intentions here, but this behaviour
> seems to be quite useless/counter-intuitive and potentially harmful:
> 
> richih@adamantium  ~ % zsh -f
> adamantium% PS1="%~ %# "
> ~ % mkdir testdir
> ~ % cd testdir
> ~/testdir % rmdir ~/testdir
> ~/testdir % cd .
> . % ls
> . % pwd
> .
> . % cd ..
> . % pwd
> .
> . %
> 
> Wouldn't it be better if zsh threw an error as soon as the user tries to `cd .`?
> 

FWIW:

stat64(".", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
chdir("/tmp/d")                 = -1 ENOENT (No such file or directory)
stat64(".", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
chdir(".")                              = 0
stat64("/tmp/d", 0xbf9b00ec)    = -1 ENOENT (No such file or directory)
stat64(".", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
rt_sigprocmask(SIG_BLOCK, [INT], [CHLD], 8) = 0
stat64("..", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
open("..", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3

which tells me two things: that there is an initial chdir() call which
fails (re your suggestion to propagate that), and that the behaviour
might be even weirder if you remove the parent directory as well.
('cd /tmp/d/e && rm -rf /tmp/d') 

> 
> Thanks,
> Richard


  reply	other threads:[~2012-03-27  5:22 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 [this message]
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
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=20120327051343.GB27197@daniel3.local \
    --to=d.s@daniel.shahaf.name \
    --cc=richih.mailinglist@gmail.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).