summaryrefslogtreecommitdiffstats
path: root/src/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.go')
-rw-r--r--src/reader.go38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/reader.go b/src/reader.go
index 494a2f72..ce5950d7 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -6,14 +6,13 @@ import (
"io"
"os"
"os/exec"
- "path"
"path/filepath"
"sync"
"sync/atomic"
"time"
+ "github.com/charlievieth/fastwalk"
"github.com/junegunn/fzf/src/util"
- "github.com/saracen/walker"
)
// Reader reads from command or standard input
@@ -77,14 +76,13 @@ func (r *Reader) fin(success bool) {
func (r *Reader) terminate() {
r.mutex.Lock()
- defer func() { r.mutex.Unlock() }()
-
r.killed = true
if r.exec != nil && r.exec.Process != nil {
util.KillCommand(r.exec)
- } else if defaultCommand != "" {
+ } else {
os.Stdin.Close()
}
+ r.mutex.Unlock()
}
func (r *Reader) restart(command string) {
@@ -99,24 +97,9 @@ func (r *Reader) ReadSource() {
r.startEventPoller()
var success bool
if util.IsTty() {
- // The default command for *nix requires a shell that supports "pipefail"
- // https://unix.stackexchange.com/a/654932/62171
- shell := "bash"
- currentShell := os.Getenv("SHELL")
- currentShellName := path.Base(currentShell)
- for _, shellName := range []string{"bash", "zsh", "ksh", "ash", "hush", "mksh", "yash"} {
- if currentShellName == shellName {
- shell = currentShell
- break
- }
- }
cmd := os.Getenv("FZF_DEFAULT_COMMAND")
if len(cmd) == 0 {
- if defaultCommand != "" {
- success = r.readFromCommand(&shell, defaultCommand)
- } else {
- success = r.readFiles()
- }
+ success = r.readFiles()
} else {
success = r.readFromCommand(nil, cmd)
}
@@ -163,10 +146,14 @@ func (r *Reader) readFromStdin() bool {
func (r *Reader) readFiles() bool {
r.killed = false
- fn := func(path string, mode os.FileInfo) error {
+ conf := fastwalk.Config{Follow: true}
+ fn := func(path string, de os.DirEntry, err error) error {
+ if err != nil {
+ return nil
+ }
path = filepath.Clean(path)
if path != "." {
- isDir := mode.Mode().IsDir()
+ isDir := de.IsDir()
if isDir && filepath.Base(path)[0] == '.' {
return filepath.SkipDir
}
@@ -181,10 +168,7 @@ func (r *Reader) readFiles() bool {
}
return nil
}
- cb := walker.WithErrorCallback(func(pathname string, err error) error {
- return nil
- })
- return walker.Walk(".", fn, cb) == nil
+ return fastwalk.Walk(&conf, ".", fn) == nil
}
func (r *Reader) readFromCommand(shell *string, command string) bool {