bug-bash
[Top][All Lists]
Advanced

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

Re: pwd and prompt don't update after deleting current working directory


From: David Hedlund
Subject: Re: pwd and prompt don't update after deleting current working directory
Date: Fri, 12 Jul 2024 04:31:40 +0200
User-agent: Mozilla Thunderbird

On 2024-07-12 04:19, David wrote:
n Thu, 11 Jul 2024 at 22:14, David Hedlund<davidh@gnu.org>  wrote:

When a directory is deleted while the user is inside it, the terminal
should automatically return to the parent directory.
Hi, I disagree, and I think if you understand better why this occurs, you
will understand why knowledgable users will disagree, and you will
change your opinion.

This is a fundamental aspect of how Unix-like operating systems work,
and it will not be changed because it is very useful in other situations.
It occurs because of the designed behaviour of the 'unlink' system call.
You can read about that in 'man 2 unlink'.

#### Expected behaviour
When a directory is deleted while the user is inside it, the terminal
should automatically return to the parent directory.
#### Actual behaviour
The terminal remains in the deleted directory's path, even though the
directory no longer exists.
Your final phrase there "the directory no longer exists" is incorrect.

The directory does still exist. The 'rm' command did not destroy it.
Any processes that have already opened it can continue to use it.
The terminal is one of those processes.

Deleting any file (including your directory, because directories have
file-like behaviour in this respect, same as every other directory entry)
just removes that file object from its parent directory entries. It does
not destroy the file in any way. That means that no new processes
can access the file, because now there's no normal way to discover
that it exists, because it no longer appears in its parent directory entries.
But any process that already has the file open can continue to use it.

So your directory does not cease to exist until nothing is using it, and
even then it is not destroyed, merely forgotten entirely.

Here's more explanation:
   https://en.wikipedia.org/wiki/Rm_(Unix)#Overview

I understand. So the feature request should be an option "-b" (for bounce out of the directory when deleted) for example?


reply via email to

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