mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-02 14:10:32 +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:
@@ -20,6 +20,7 @@ CHANGELOG
|
|||||||
- Fixed AWK tokenizer not treating a new line character as whitespace
|
- Fixed AWK tokenizer not treating a new line character as whitespace
|
||||||
- Fixed `--{accept,with}-nth` removing trailing whitespaces with a non-default `--delimiter`
|
- 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 OSC8 hyperlinks being mangled when the URL contains unicode characters (#4707)
|
||||||
|
- Fixed `--with-shell` not handling quoted arguments correctly (#4709)
|
||||||
|
|
||||||
0.70.0
|
0.70.0
|
||||||
------
|
------
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/junegunn/go-shellwords"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ type Executor struct {
|
|||||||
|
|
||||||
func NewExecutor(withShell string) *Executor {
|
func NewExecutor(withShell string) *Executor {
|
||||||
shell := os.Getenv("SHELL")
|
shell := os.Getenv("SHELL")
|
||||||
args := strings.Fields(withShell)
|
args, err := shellwords.Parse(withShell)
|
||||||
if len(args) > 0 {
|
if err == nil && len(args) > 0 {
|
||||||
shell = args[0]
|
shell = args[0]
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user