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

When handling bookmark, use readlink, not realpath #1773

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

7ocb
Copy link

@7ocb 7ocb commented Nov 22, 2023

This is to cd to path as it pointed by symlink, not to it's real path. Bookmarked directory may itself contain symlinks in path, which should be respected.

For example: if directory is physically in /mnt/storage/some and it's symlinked to ~/some and directory ~/some/dir added to bookmarks, it's reasonable to expect that when following bookmark directory will be changed to ~/some/dir (as in bookmark's link) not to /mnt/storage/some/dir (as dir real path).

It's reasonable to expect this behavior because this follows the cd behavior (both shell cd and nnn changing directory) when changing directory into symlink.

Also, with behavior as in this PR user can have both bookmarks to "short" path (i.e. ~/some/dir in example above) and long path (i.e. /mnt/storage/some/dir) - which path is actually bookmarked, that path will be followed. Original behavior disallows using bookmarks to go to "short" path.

src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Show resolved Hide resolved
@7ocb 7ocb force-pushed the handle-link-by-readlink-not-realpath-mk2 branch from fd98436 to e5a2587 Compare November 22, 2023 17:02
src/nnn.c Outdated Show resolved Hide resolved
@7ocb 7ocb force-pushed the handle-link-by-readlink-not-realpath-mk2 branch from e5a2587 to 6628fb0 Compare November 22, 2023 17:19
Copy link
Collaborator

@N-R-K N-R-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work fine. A couple style nits.

src/nnn.c Outdated Show resolved Hide resolved
src/nnn.c Outdated Show resolved Hide resolved
This is to cd to path as it pointed by symlink, not to it's real path. Bookmarked directory may itself contain symlinks in path, which should be respected.

For example: if directory is physically in /mnt/storage/some and it's symlinked to ~/some and directory ~/some/dir added to bookmarks, it's expected that when following bookmark directory will be changed to ~/some/dir (as in bookmark's link) not to /mnt/storage/some/dir (as dir real path).
@7ocb 7ocb force-pushed the handle-link-by-readlink-not-realpath-mk2 branch from 6628fb0 to 9aaf949 Compare November 22, 2023 17:42
@jarun jarun merged commit 404eed5 into jarun:master Nov 25, 2023
7 checks passed
@jarun
Copy link
Owner

jarun commented Nov 25, 2023

Thanks guys!

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants