From b59f27ef5aba64e20d4415538fa2f460977a0cba Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 9 Mar 2026 22:09:27 +0900 Subject: [PATCH] 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' --- CHANGELOG.md | 1 + src/util/util_unix.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3736a6a1..83e4448c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ CHANGELOG - Fixed AWK tokenizer not treating a new line character as whitespace - Fixed `--{accept,with}-nth` removing trailing whitespaces with a non-default `--delimiter` - Fixed OSC8 hyperlinks being mangled when the URL contains unicode characters (#4707) + - Fixed `--with-shell` not handling quoted arguments correctly (#4709) 0.70.0 ------ diff --git a/src/util/util_unix.go b/src/util/util_unix.go index 5a67066b..736fa016 100644 --- a/src/util/util_unix.go +++ b/src/util/util_unix.go @@ -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 {