zimbatm / h

faster shell navigation of projects
MIT License
50 stars 4 forks source link

`up` and symlinks #3

Closed danbst closed 4 years ago

danbst commented 4 years ago

I have:

[danbst@station:~/code/github.com/nixos]$ ls -l
total 0
lrwxrwxrwx 1 danbst users 24 січ 19 16:39 nixpkgs -> /home/danbst/dev/nixpkgs

I jump into ~/code/github.com/nixos/nixpkgs/pkgs/top-level and try to jump up:

[danbst@station:~/code/github.com/nixos/nixpkgs/pkgs/top-level]$ up

[danbst@station:~/dev/nixpkgs]$ 

I'm following symlink, which is awkward. I expected to end up in ~/code/github.com/nixos/nixpkgs.

(kinda related, but won't help here - for a long time fish had same problem with cd, https://github.com/fish-shell/fish-shell/issues/3350)

zimbatm commented 4 years ago

hmm yeah that's awkward. Not sure what the problem is...

zimbatm commented 4 years ago

it looks like Pathname.pwd and Dir.pwd resolve the symlinks

zimbatm commented 4 years ago

ruby calls getcwd() internally, which returns the resolved current directory. This is so weird, check this out:

setup:

cd /tmp
mkdir foo
ln -s foo bar
cd /tmp/bar

now:

$ pwd
/tmp/bar
$ strace pwd 2>/dev/null
/tmp/foo