mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-21 21:47:32 +02:00
add extra quoting for shell cmd string on linux
This solves an issue where we could not open files with names that contained spaces and single quotes. It also solves an issue of variable expansion for files with some kind of environment variables on the name e.g. '$USER.txt'
This commit is contained in:
parent
fb69bfd20d
commit
028cb2be2f
@ -301,10 +301,15 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
|
||||
// OpenFile opens a file with the given
|
||||
func (c *OSCommand) OpenFile(filename string) error {
|
||||
commandTemplate := c.Config.GetUserConfig().OS.OpenCommand
|
||||
templateValues := map[string]string{
|
||||
"filename": c.Quote(filename),
|
||||
quoted := c.Quote(filename)
|
||||
if c.Platform.OS == "linux" {
|
||||
// Add extra quoting to avoid issues with shell command string
|
||||
quoted = c.Quote(quoted)
|
||||
quoted = quoted[1 : len(quoted)-1]
|
||||
}
|
||||
templateValues := map[string]string{
|
||||
"filename": quoted,
|
||||
}
|
||||
|
||||
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
|
||||
err := c.RunCommand(command)
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user