[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 |
Subject: |
Re: pwd and prompt don't update after deleting current working directory |
Date: |
Fri, 12 Jul 2024 02:19:07 +0000 |
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
- Re: pwd and prompt don't update after deleting current working directory, (continued)
- Re: pwd and prompt don't update after deleting current working directory, Chet Ramey, 2024/07/12
- Re: pwd and prompt don't update after deleting current working directory, David Hedlund, 2024/07/16
- Re: pwd and prompt don't update after deleting current working directory, Chet Ramey, 2024/07/16
- Re: pwd and prompt don't update after deleting current working directory, Lawrence Velázquez, 2024/07/16
- Re: pwd and prompt don't update after deleting current working directory, David Hedlund, 2024/07/16
- Re: pwd and prompt don't update after deleting current working directory, Martin D Kealey, 2024/07/19
- Re: pwd and prompt don't update after deleting current working directory, David Hedlund, 2024/07/19
Re: pwd and prompt don't update after deleting current working directory, Robert Elz, 2024/07/11
Re: pwd and prompt don't update after deleting current working directory,
David <=