mate-desktop / mate-terminal

The MATE Terminal Emulator
http://www.mate-desktop.org
GNU General Public License v3.0
133 stars 73 forks source link

bash: pwd and prompt don't update after deleting current working directory #459

Closed davidhedlund closed 1 month ago

davidhedlund commented 1 month ago

When a directory is deleted while the user is inside it, the terminal should automatically return to the parent directory.

Expected behaviour

When a directory is deleted while the user is inside it, the terminal should automatically return to the parent directory.

user@domain:~/test$ mkdir ~/test && cd ~/test && touch foo && ls
foo
user@domain:~/test$ rm -r ~/test
user@domain:~/$ 

Actual behaviour

The terminal remains in the deleted directory's path, even though the directory no longer exists.

Steps to reproduce the behaviour

Create a new directory and navigate into it:

user@domain:~/test$ mkdir ~/test && cd ~/test && touch foo && ls
foo

Delete the directory while still inside it:

user@domain:~/test$ rm -r ~/test

MATE general version

1.26.0

Package version

1.26.0

Linux Distribution

Ubuntu MATE 22.04

Link to bugreport of your Distribution (requirement)

https://bugs.launchpad.net/ubuntu/+bug/2072706

cwendling commented 1 month ago

I don't think this should concern MATE-Terminal, it's a question of the shell itself IMO. I guess it's doable (as we can pick up the hostname & pwd for the tab title & al), but I don't think it's desirable to introduce this kind of behavior.

In Bash, you can use PROMPT_COMMAND^1, e.g. :warning: barely tested:

PROMPT_COMMAND='__d="$PWD"; while test "$__d" != / && ! test -d "$__d"; do __d="${__d%/*}"; cd "${__d}" 2>/dev/null && break; done'
davidhedlund commented 1 month ago

I don't think this should concern MATE-Terminal, it's a question of the shell itself IMO.

Thank you for your help again.

This has been reported as a feature request to bug-bash@gnu.org.