Skip to content

Commit

Permalink
Use $SHELL instead of bash if it's known to support 'pipefail'
Browse files Browse the repository at this point in the history
when running the default find command

Close #3339
Close #3364
  • Loading branch information
junegunn committed Jul 12, 2023
1 parent 0130f64 commit 547e101
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"os/exec"
"path"
"path/filepath"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -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 != "" {
Expand Down

0 comments on commit 547e101

Please sign in to comment.