summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-02-07 01:49:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-02-07 01:49:29 +0900
commite95d82748fc8fe5a05d93b30388ba37adb7dbac8 (patch)
treed59019cea080cd5c5afb6864ae5c55832d0b4285
parent30bd0b53dbf804a96db4c13d787771b3924d6634 (diff)
Use $SHELL to start $FZF_DEFAULT_COMMAND (#481)
-rw-r--r--src/reader.go3
-rw-r--r--src/terminal.go7
-rw-r--r--src/util/util.go10
3 files changed, 12 insertions, 8 deletions
diff --git a/src/reader.go b/src/reader.go
index 3e2cf0a0..85cbf8be 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -4,7 +4,6 @@ import (
"bufio"
"io"
"os"
- "os/exec"
"github.com/junegunn/fzf/src/util"
)
@@ -59,7 +58,7 @@ func (r *Reader) readFromStdin() {
}
func (r *Reader) readFromCommand(cmd string) {
- listCommand := exec.Command("sh", "-c", cmd)
+ listCommand := util.ExecCommand(cmd)
out, err := listCommand.StdoutPipe()
if err != nil {
return
diff --git a/src/terminal.go b/src/terminal.go
index 181b9c06..f1ddc48e 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"os"
- "os/exec"
"os/signal"
"regexp"
"sort"
@@ -720,11 +719,7 @@ func quoteEntry(entry string) string {
func executeCommand(template string, replacement string) {
command := strings.Replace(template, "{}", replacement, -1)
- shell := os.Getenv("SHELL")
- if len(shell) == 0 {
- shell = "sh"
- }
- cmd := exec.Command(shell, "-c", command)
+ cmd := util.ExecCommand(command)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
diff --git a/src/util/util.go b/src/util/util.go
index e7e4f313..ab9e7664 100644
--- a/src/util/util.go
+++ b/src/util/util.go
@@ -5,6 +5,7 @@ import "C"
import (
"os"
+ "os/exec"
"time"
"unicode/utf8"
)
@@ -126,3 +127,12 @@ func TrimLen(runes []rune) int {
}
return i - j + 1
}
+
+// ExecCommand executes the given command with $SHELL
+func ExecCommand(command string) *exec.Cmd {
+ shell := os.Getenv("SHELL")
+ if len(shell) == 0 {
+ shell = "sh"
+ }
+ return exec.Command(shell, "-c", command)
+}