diff options
-rw-r--r-- | docs/Config.md | 4 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 16 | ||||
-rw-r--r-- | pkg/config/config_linux.go | 4 | ||||
-rw-r--r-- | pkg/config/config_windows.go | 4 |
4 files changed, 11 insertions, 17 deletions
diff --git a/docs/Config.md b/docs/Config.md index bc09575bb..99c44855b 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -211,14 +211,14 @@ keybinding: ```yaml os: - openCommand: 'cmd /c "start "" {{filename}}"' + openCommand: 'start "" {{filename}}' ``` ### Linux ```yaml os: - openCommand: 'sh -c "xdg-open {{filename}} >/dev/null"' + openCommand: 'xdg-open {{filename}} >/dev/null' ``` ### OSX diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index b146d9d8e..d560f6d57 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -202,7 +202,7 @@ 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 = commandStr + quotedCommand = strings.Replace(commandStr, "&", "^&", -1) } else { quotedCommand = c.Quote(commandStr) } @@ -252,7 +252,7 @@ func (c *OSCommand) RunCommand(formatString string, formatArgs ...interface{}) e // RunShellCommand runs shell commands i.e. 'sh -c <command>'. Good for when you // need access to the shell func (c *OSCommand) RunShellCommand(command string) error { - cmd := c.Command(c.Platform.Shell, c.Platform.ShellArg, command) + cmd := c.ShellCommandFromString(command) c.LogExecCmd(cmd) _, err := sanitisedCommandOutput(cmd.CombinedOutput()) @@ -288,17 +288,11 @@ 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 - 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, + "filename": c.Quote(filename), } command := utils.ResolvePlaceholderString(commandTemplate, templateValues) - err := c.RunCommand(command) + err := c.RunShellCommand(command) return err } @@ -311,7 +305,7 @@ func (c *OSCommand) OpenLink(link string) error { } command := utils.ResolvePlaceholderString(commandTemplate, templateValues) - err := c.RunCommand(command) + err := c.RunShellCommand(command) return err } diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index fe75b7322..dd5708a53 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -5,7 +5,7 @@ func GetPlatformDefaultConfig() OSConfig { return OSConfig{ EditCommand: ``, EditCommandTemplate: `{{editor}} {{filename}}`, - OpenCommand: `sh -c "xdg-open {{filename}} >/dev/null"`, - OpenLinkCommand: `sh -c "xdg-open {{link}} >/dev/null"`, + OpenCommand: `xdg-open {{filename}} >/dev/null`, + OpenLinkCommand: `xdg-open {{link}} >/dev/null`, } } diff --git a/pkg/config/config_windows.go b/pkg/config/config_windows.go index fb42689a9..301eecec1 100644 --- a/pkg/config/config_windows.go +++ b/pkg/config/config_windows.go @@ -5,7 +5,7 @@ func GetPlatformDefaultConfig() OSConfig { return OSConfig{ EditCommand: ``, EditCommandTemplate: `{{editor}} {{filename}}`, - OpenCommand: `cmd /c start "" {{filename}}`, - OpenLinkCommand: `cmd /c start "" {{link}}`, + OpenCommand: `start "" {{filename}}`, + OpenLinkCommand: `start "" {{link}}`, } } |