summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-05-14 01:30:36 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-05-14 01:54:30 +0900
commit6432f00f0d026c61f683c83ded4d2e15317e927e (patch)
tree7dd666c371e04e5c91f704b8a6d48a9d452e5c82 /src/util
parent4e9e842aa4df67051ce88963b0745679dbaeadb5 (diff)
downloadfzf-6432f00f0d026c61f683c83ded4d2e15317e927e.tar.gz
0.52.1
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util_windows.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/util/util_windows.go b/src/util/util_windows.go
index f29e33be..3a4ab570 100644
--- a/src/util/util_windows.go
+++ b/src/util/util_windows.go
@@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "regexp"
"strings"
"sync/atomic"
"syscall"
@@ -20,6 +21,8 @@ const (
shellTypePowerShell
)
+var escapeRegex = regexp.MustCompile(`[&|<>()^%!"]`)
+
type Executor struct {
shell string
shellType shellType
@@ -131,7 +134,9 @@ func escapeArg(s string) string {
b = append(b, '\\')
}
b = append(b, '"')
- return string(b)
+ return escapeRegex.ReplaceAllStringFunc(string(b), func(match string) string {
+ return "^" + match
+ })
}
func (x *Executor) QuoteEntry(entry string) string {