summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2021-10-12 21:08:32 +0900
committerJesse Duffield <jessedduffield@gmail.com>2021-10-16 22:40:50 +1100
commit92f03a7872534657e0857cc72a51bdfca1fddb54 (patch)
tree80e1c2fa855f4ba430ca74d314c2f13ed1bc2beb
parent2dc8396debb38c11b66fe40ca2ebd69aed68faa0 (diff)
Escape special characters
-rw-r--r--pkg/commands/oscommands/os.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index d560f6d57..b6181364f 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -202,7 +202,13 @@ func (c *OSCommand) ShellCommandFromString(commandStr string) *exec.Cmd {
quotedCommand := ""
// Windows does not seem to like quotes around the command
if c.Platform.OS == "windows" {
- quotedCommand = strings.Replace(commandStr, "&", "^&", -1)
+ quotedCommand = commandStr
+ quotedCommand = strings.Replace(quotedCommand, "^", "^^", -1)
+ quotedCommand = strings.Replace(quotedCommand, "&", "^&", -1)
+ quotedCommand = strings.Replace(quotedCommand, "|", "^|", -1)
+ quotedCommand = strings.Replace(quotedCommand, "<", "^<", -1)
+ quotedCommand = strings.Replace(quotedCommand, ">", "^>", -1)
+ quotedCommand = strings.Replace(quotedCommand, "%", "^%", -1)
} else {
quotedCommand = c.Quote(commandStr)
}