summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2021-10-09 16:32:36 +0900
committerJesse Duffield <jessedduffield@gmail.com>2021-10-16 22:40:50 +1100
commit7b615e31860c1ea56ddc5813b81a8f20d012af34 (patch)
tree658cca8291f07f5355537d3d30007b9758d833aa /pkg/commands
parenta2108362de43a8cdab48151f84142b833f0d3d98 (diff)
Fix open link command in Windows
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/oscommands/os.go16
1 files changed, 5 insertions, 11 deletions
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
}