summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandshot <randshot@norealm.xyz>2020-07-14 21:43:12 +0200
committerJesse Duffield <jessedduffield@gmail.com>2020-07-15 09:41:16 +1000
commit5dfa26ea8b32c867bb583497bb729de47c4a1c1f (patch)
tree234d3ce04749391b9d4555e6482b6236bca78d14
parentdbf042b8adc12b3cfb2d803c124e35b9fe93f317 (diff)
use strconv for quoting in 'GitCommand.Commit' and 'OSCommand.ShellCommandFromString'
use raw strings for the escaped quotes in 'os_default_platform.go' and 'os_windows.go' Signed-off-by: Randshot <randshot@norealm.xyz>
-rw-r--r--pkg/commands/git.go2
-rw-r--r--pkg/commands/os.go6
-rw-r--r--pkg/commands/os_default_platform.go4
-rw-r--r--pkg/commands/os_windows.go2
4 files changed, 8 insertions, 6 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 3599f7b39..0e4fa2aec 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -451,7 +451,7 @@ func (c *GitCommand) usingGpg() bool {
// Commit commits to git
func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) {
- command := fmt.Sprintf("git commit %s -m %s", flags, c.OSCommand.Quote(message))
+ command := fmt.Sprintf("git commit %s -m %s", flags, strconv.Quote(message))
if c.usingGpg() {
return c.OSCommand.ShellCommandFromString(command), nil
}
diff --git a/pkg/commands/os.go b/pkg/commands/os.go
index b3358b170..f4efe7b14 100644
--- a/pkg/commands/os.go
+++ b/pkg/commands/os.go
@@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
+ "strconv"
"strings"
"sync"
@@ -125,10 +126,11 @@ func (c *OSCommand) ShellCommandFromString(commandStr string) *exec.Cmd {
if c.Platform.os == "windows" {
quotedCommand = commandStr
} else {
- quotedCommand = c.Quote(commandStr)
+ quotedCommand = strconv.Quote(commandStr)
}
- return c.ExecutableFromString(fmt.Sprintf("%s %s %s", c.Platform.shell, c.Platform.shellArg, quotedCommand))
+ shellCommand := fmt.Sprintf("%s %s %s", c.Platform.shell, c.Platform.shellArg, quotedCommand)
+ return c.ExecutableFromString(shellCommand)
}
// RunCommandWithOutputLive runs RunCommandWithOutputLiveWrapper
diff --git a/pkg/commands/os_default_platform.go b/pkg/commands/os_default_platform.go
index 864b1f3c8..9411e69a6 100644
--- a/pkg/commands/os_default_platform.go
+++ b/pkg/commands/os_default_platform.go
@@ -12,9 +12,9 @@ func getPlatform() *Platform {
catCmd: "cat",
shell: "bash",
shellArg: "-c",
- escapedQuote: "'",
openCommand: "open {{filename}}",
openLinkCommand: "open {{link}}",
- fallbackEscapedQuote: "\"",
+ escapedQuote: `\'`,
+ fallbackEscapedQuote: `\"`,
}
}
diff --git a/pkg/commands/os_windows.go b/pkg/commands/os_windows.go
index fcb498db3..74c846912 100644
--- a/pkg/commands/os_windows.go
+++ b/pkg/commands/os_windows.go
@@ -7,6 +7,6 @@ func getPlatform() *Platform {
shell: "cmd",
shellArg: "/c",
escapedQuote: `\"`,
- fallbackEscapedQuote: "\\'",
+ fallbackEscapedQuote: `\'`,
}
}