summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-06-13 22:54:13 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-06-13 22:55:31 +0900
commit9dc3ed638a1c5bc7a7d4918eb736cd82c8cb3fa0 (patch)
tree075a1699d57660ee08e8c38a57638370062a96d7
parent0acace1ace0605829ec4cb2cee4153582071ba0c (diff)
downloadfzf-9dc3ed638a1c5bc7a7d4918eb736cd82c8cb3fa0.tar.gz
--walker-skip should also handle symlinks to directories
Fix #3858
-rw-r--r--src/reader.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/reader.go b/src/reader.go
index 528f370b..f39f47f5 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"io"
+ "io/fs"
"os"
"os/exec"
"path/filepath"
@@ -222,6 +223,16 @@ func (r *Reader) readFromStdin() bool {
return true
}
+func isSymlinkToDir(path string, de os.DirEntry) bool {
+ if de.Type()&fs.ModeSymlink == 0 {
+ return false
+ }
+ if s, err := os.Stat(path); err == nil {
+ return s.IsDir()
+ }
+ return false
+}
+
func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool {
r.killed = false
conf := fastwalk.Config{Follow: opts.follow}
@@ -232,7 +243,7 @@ func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool
path = filepath.Clean(path)
if path != "." {
isDir := de.IsDir()
- if isDir {
+ if isDir || opts.follow && isSymlinkToDir(path, de) {
base := filepath.Base(path)
if !opts.hidden && base[0] == '.' {
return filepath.SkipDir