summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-07-12 13:55:59 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-07-12 13:55:59 +0900
commit547e101f1d6bf326d286bac0fb3272738a92a67f (patch)
tree85ee8c9cbb9e8470ef0568f50ce38435f2f1789a /src
parent0130f64934d2a3ac4f5639ed16cf3dbcfb38240b (diff)
downloadfzf-547e101f1d6bf326d286bac0fb3272738a92a67f.tar.gz
Use $SHELL instead of bash if it's known to support 'pipefail'
when running the default find command Close #3339 Close #3364
Diffstat (limited to 'src')
-rw-r--r--src/reader.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/reader.go b/src/reader.go
index 06e9b734..494a2f72 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -6,6 +6,7 @@ import (
"io"
"os"
"os/exec"
+ "path"
"path/filepath"
"sync"
"sync/atomic"
@@ -98,8 +99,17 @@ func (r *Reader) ReadSource() {
r.startEventPoller()
var success bool
if util.IsTty() {
- // The default command for *nix requires bash
+ // 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 != "" {