1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-05 15:15:49 +02:00

fix: escape quote character on Linux

Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>

Closes #269
This commit is contained in:
Sascha Andres 2018-09-10 06:34:26 +02:00
parent 5a0431bb62
commit 717913e64c

View File

@ -140,6 +140,13 @@ func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) *ex
// Quote wraps a message in platform-specific quotation marks
func (c *OSCommand) Quote(message string) string {
message = strings.Replace(message, "`", "\\`", -1)
if c.Platform.os == "linux" {
if strings.ContainsRune(message, '\'') {
c.Platform.escapedQuote = `"`
} else {
c.Platform.escapedQuote = `'`
}
}
return c.Platform.escapedQuote + message + c.Platform.escapedQuote
}