mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-10 04:07:18 +02:00
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>
This commit is contained in:
parent
dbf042b8ad
commit
5dfa26ea8b
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -12,9 +12,9 @@ func getPlatform() *Platform {
|
||||
catCmd: "cat",
|
||||
shell: "bash",
|
||||
shellArg: "-c",
|
||||
escapedQuote: "'",
|
||||
openCommand: "open {{filename}}",
|
||||
openLinkCommand: "open {{link}}",
|
||||
fallbackEscapedQuote: "\"",
|
||||
escapedQuote: `\'`,
|
||||
fallbackEscapedQuote: `\"`,
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,6 @@ func getPlatform() *Platform {
|
||||
shell: "cmd",
|
||||
shellArg: "/c",
|
||||
escapedQuote: `\"`,
|
||||
fallbackEscapedQuote: "\\'",
|
||||
fallbackEscapedQuote: `\'`,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user