summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorFrancisco Miamoto <fsmiamoto@gmail.com>2021-05-31 19:53:27 -0300
committerJesse Duffield <jessedduffield@gmail.com>2021-07-27 20:28:00 +1000
commit028cb2be2f844b6563ac906e8066df184753fa8c (patch)
treee424ebcd768230b4f1d4cd9efd9c271264c29827 /pkg/commands
parentfb69bfd20dbcad1c96b8d830447335b74e2b6938 (diff)
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'
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/oscommands/os.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index 2922313b8..cf050cf53 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -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
+ 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": c.Quote(filename),
+ "filename": quoted,
}
-
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
err := c.RunCommand(command)
return err