[BUG] `-e` overrides `--no-follow` behavior and includes symlinks into results
non-descriptive opened this issue · 1 comments
Checks
- I have read the troubleshooting section and still think this is a bug.
Describe the bug you encountered:
If symlink has extension in the name and fd
query has it's extension the file will be included into result ignoring default --no-follow
behavior.
Considering ripgrep
share ignore
crate its --no-follow
behavior works as expected and skips all kinds of symlinks completely.
Steps to reproduce
# create some folders files and symlinks
mkdir walk sym
echo "AAAA" > ./sym/file.txt
ln -rs sym/file.txt walk/file.txt # symlink to a file with extension in it's name
ln -rs sym/file.txt walk/link # symlink with no extension
ln -rs sym/ walk/sym # symlink to folder
ln -rs sym/ walk/sym.txt # symlink to folder with .txt in it's name
# check structure of target folder
ls -l walk
> lrwxrwxrwx 15 user file -> ../sym/file.txt
> lrwxrwxrwx 15 user file.txt -> ../sym/file.txt
> lrwxrwxrwx 6 user sym -> ../sym
# The issue. Output should be empty, but isn't
fd -e txt . "./walk"
> ./walk/file.txt
> ./walk/sym.txt
Describe what you expected to happen:
fd
skips all the symlinks before filtering for extension, regardless of it's file/folder name it's walking or at least has option to completely ignore it.
What version of fd
are you using?
fd 9.0.0
Which operating system / distribution are you on?
Linux 6.1.0-12-amd64 x86_64
fd
does not ignore symlinks by default, it just doesn't follow them. They are treated basically like regular files so the filename can still match. If you want to totally ignore symlinks you can use something like
tavianator@graphene $ fd -tf -e txt .
sym/file.txt
For completeness, you could list every possible type except links:
tavianator@graphene $ fd -tf -td -tb -tc -ts -tp -e txt .
sym/file.txt