bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PWD bug


From: Bob Proulx
Subject: Re: PWD bug
Date: Wed, 30 Oct 2002 18:37:40 -0700
User-agent: Mutt/1.4i

K-Sudhakaran <address@hidden> [2002-10-24 15:51:44 +0530]:
> Do the following in bash shell ...u will get to know the bug in it.
> 
> Create a sub directory.
> 
> get into that directory using 'cd' command.
> 
> remove the present working directory using rm ~/Newlycreateddirectory with
> -rf swtiches.
> 
> it removes the directory successfully.

Yes.  The filesystem is reference counted.  Blocks are actually only
removed when the last reference goes to zero.  Since you are there
with a current working directory that directory has a non-zero
reference count.  But the pointer to it from the above directory has
been removed.

> But if u see the content of the PWD environment variable it is not updated
> and hence forth the prompt of the shell ( if we have made use of the PWD
> as a command prompt ).

PWD is a shell variable, such as a /bin/bash, /bin/csh, or other shell
variable.  It has nothing to do with fileutils.

> Either it should not allow us to remove the Present working directory
> or it should take us to the next immediate outer directory available.
> 
> You may contact me for further clarrifications about this bug.

What you are seeing is not a bug but the expected behavior.  Because
of your phrasing I am sure I will not be able to convince you
otherwise.  But you will just have to trust me that what you are
seeing is the right behavior.

After you have removed a directory you are sitting in, how would you
cause an update to the prompt of another process?  There is no link to
it.  There is no way to get there.  You have climbed up a tree and out
on a limb.  You have taken a saw and cut off the limb between you and
the trunk.  The only difference is that you were not injured by
removing your own current working directory.

You mention your prompt.  The best you could do is cause your prompt
to be updated with a calculated pwd with every prompt instead of using
the shell built-in $PWD variable.  At that point in time when you
prompt again you will be notified that your directory has been removed
out from under yourself.  But that seems like a huge amount of
overhead for this odd case.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]