Skip to content
Myr

Revert default command: find with -fstype required

Before adoption: this commit came in with the history the project adopted, so no landing records it.

In #1061 we changed the default command to retry with a simpler find command with fewer arguments if the first find command failed. This was to support stripped-down verions of find that do not support -fstype argument. However, this caused an unwanted side-effect of yielding duplicate entries when the first command failed after producing some lines. We revert the change in this commit, so the default command will not work with find without -fstype support. But we now print better error message in that case so that the user can set up a working $FZF_DEFAULT_COMMAND. Close #1120 #1167

authored by Junegunn Choi · committed by Junegunn Choi · parent 1e5bd55 · Browse files · 2 files+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−2 removed

  • other:+6 added−2 removed

2 files+6 added−2 removed

modified:src/constants.go+1 added-1 removed
53 unmodified lines
54var defaultCommand string5556func init() {57 if !util.IsWindows() {58 defaultCommand = `set -o pipefail; (command find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune -o -type f -print -o -type l -print || command find -L . -mindepth 1 -path '*/\.*' -prune -o -type f -print -o -type l -print) 2> /dev/null | cut -b3-`58 defaultCommand = `set -o pipefail; command find -L . -mindepth 1 \( -path '*/\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-`59 } else if os.Getenv("TERM") == "cygwin" {60 defaultCommand = `sh -c "command find -L . -mindepth 1 -path '*/\.*' -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-"`61 } else {62 defaultCommand = `dir /s/b`
20 unmodified lines
modified:src/terminal.go+5 added-1 removed
689 unmodified lines
690 if t.progress > 0 && t.progress < 100 {691 output += fmt.Sprintf(" (%d%%)", t.progress)692 }693 if !t.success && t.count == 0 {694 output += " [ERROR]"694 if len(os.Getenv("FZF_DEFAULT_COMMAND")) > 0 {695 output = "[$FZF_DEFAULT_COMMAND failed]"696 } else {697 output = "[default command failed - $FZF_DEFAULT_COMMAND required]"698 }699 }700 if pos+len(output) <= t.window.Width() {701 t.window.CPrint(tui.ColInfo, 0, output)702 }
1162 unmodified lines