mirror of
https://github.com/junegunn/fzf.git
synced 2026-03-26 10:36:52 +08:00
Fix --with-shell not handling quoted arguments correctly
Fix #4709 Use go-shellwords instead of strings.Fields to parse --with-shell, so paths with spaces can be properly quoted. ln -s /bin/bash "/tmp/ba sh" fzf --with-shell='/tmp/ba\ sh -c' --preview 'echo hello world' fzf --with-shell='"/tmp/ba sh" -c' --preview 'echo hello world'
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/junegunn/go-shellwords"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -20,8 +21,8 @@ type Executor struct {
|
||||
|
||||
func NewExecutor(withShell string) *Executor {
|
||||
shell := os.Getenv("SHELL")
|
||||
args := strings.Fields(withShell)
|
||||
if len(args) > 0 {
|
||||
args, err := shellwords.Parse(withShell)
|
||||
if err == nil && len(args) > 0 {
|
||||
shell = args[0]
|
||||
args = args[1:]
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user