fish_add_path: Don't resolve symlinks

The case for symlinked directories being duplicated a lot isn't there,
but there *is* a usecase for adding the symlink rather than the
target, and that's homebrew.

E.g. homebrew installs ruby into /usr/local/Cellar/ruby/2.7.1_2/bin,
and links to it from /usr/local/opt/ruby/bin. If we add the target, we
would miss updates.

Having path entries that point to the same location isn't a big
problem - it's a path lookup, so it takes a teensy bit longer. The
canonicalization is mainly so paths don't end up duplicated via weird
spelling and so relative paths can be used.
This commit is contained in:
Fabian Homborg
2020-09-12 19:28:01 +02:00
parent 568f9031aa
commit 0072367512
4 changed files with 11 additions and 7 deletions

View File

@@ -30,19 +30,20 @@ echo $status
# CHECK: 1
functions --erase checkpath
# Not adding a link either
# Add a link to the same path.
fish_add_path -v $tmpdir/link
# CHECK: set fish_user_paths {{.*}}/link {{.*}}/bin
echo $status
# CHECK: 1
# CHECK: 0
fish_add_path -a $tmpdir/sbin
# Not printing anything because it's not verbose, the /sbin should be added at the end.
string replace -- $tmpdir '' $fish_user_paths | string join ' '
# CHECK: /bin /sbin
# CHECK: /link /bin /sbin
fish_add_path -m $tmpdir/sbin
string replace -- $tmpdir '' $fish_user_paths | string join ' '
# CHECK: /sbin /bin
# CHECK: /sbin /link /bin
set -l oldpath "$PATH"
fish_add_path -nP $tmpdir/etc | string replace -- $tmpdir ''