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

fd -L omits broken symlinks #357

Closed
lilyball opened this issue Nov 7, 2018 · 5 comments · Fixed by #497
Closed

fd -L omits broken symlinks #357

lilyball opened this issue Nov 7, 2018 · 5 comments · Fixed by #497

Comments

@lilyball
Copy link

lilyball commented Nov 7, 2018

It appears that fd -L completely omits any broken symlinks. Instead it should fall back to treating a broken symlink as though -L was not specified, which matches the observed find behavior.

Example:

> touch a
> ln -s b c
> ln -s a d
> exa
a  c@  d@
> find -L .
.
./a
./c
./d
> fd -L
a
d
>

Notice how fd -L completely omitted the broken c symlink. Continued:

> find -L . -type l
./c
> fd -L -t l
>

Notice how find is treating the broken symlink exactly as though -L were not specified.

This was tested with fd 7.2.0 on macOS 10.14.1 (18B75).

@sharkdp
Copy link
Owner

sharkdp commented Nov 8, 2018

Thank you very much for reporting this.

Notice that you can use --show-errors to see what's happening to c:

▶ fd -L --show-errors
[fd error]: ./c: No such file or directory (os error 2)
a
d

I guess it's debatable what the result should actually be. After all, you tell fd to follow symlinks, and the target for the c symlink does not exist. It's that symlink resolving that currently leads to an error.

But I think you are probably right and we should try to follow find here.

Other opinions?

@neersighted
Copy link

This just bit me today; I agree the expected behavior is to follow find here, and just list the symlink as a direntry, if de-referencing fails.

@mqudsi
Copy link
Contributor

mqudsi commented Mar 28, 2019

@sharkdp remember when we comparing the results between fish's glob and fd 🙃

@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2020

This has been fixed in #497. Thank you @neersighted and @tommilligan for your initial attempts. The final solution is a third approach that takes inspiration from both previous implementations.

@sharkdp
Copy link
Owner

sharkdp commented Mar 22, 2020

Released in fd 7.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants