Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistanc behavior when changing a symlinked folder in the current working directory #10422

Closed
JustSomeRandomUsername opened this issue Apr 5, 2024 · 1 comment
Labels

Comments

@JustSomeRandomUsername
Copy link

I will try to explain using an example:

Ihave two directorys foo and bar and a symlink link pointing to foo.

If I open a terminal and navigate into link everything works as expected.
ls returns the content of the directory and I can navigate to subfolders using cd, etc..

If I now delete the symlink link and create a new symlink link pointing to bar

The terminal that I have open from before does not allow me to navigate to subfolders of foo anymore instead it autocompletes and navigates to subfolders of bar . But ls still shows the contents of foo and I can still open files in foo with commands like cat.

These seems unintended.

Minimal Example to reproduce
Shell 1

mkdir foo/a -p
mkdir bar/b -p
ln -s foo link

Shell 2

cd link

Shell 1

rm link
ln -s bar link

Shell 2

ls            # a/
cd a          # cd: The directory 'a' does not exist
cd b

fish: 3.7.0
system: fedora 39 6.7.9-200.fc39.x86_64
terminal: xterm-256color

@faho
Copy link
Member

faho commented Apr 19, 2024

Fish, like other shells, keeps a "logical" working directory.

That means it knows about /tmp/link. But any command it runs will get the "physical" working directory, which is the directory that was originally behind the link.

Other shells will behave the same way, and if you start a sub-fish it will think it is in "/tmp/foo" as well (because it asks the kernel for the working directory).

@faho faho closed this as completed Apr 19, 2024
@faho faho added the question label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants