create: Pass editor arguments from newContentEditor correctly
authorBhavin Gandhi <bhavin7392@gmail.com>
Thu, 15 Oct 2020 15:23:48 +0000 (20:53 +0530)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 24 Oct 2020 18:34:03 +0000 (20:34 +0200)
If newContentEditor has editor name with arguments like `emacsclient
-n`, it fails with `executable file not found in $PATH`. This change
parses the value correctly and passes it to the given editor.

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
create/content.go

index 0e05adf93de75ebb67b4545c6cb05bd0d2616436..13e66820198ab7ad7d9363068e8ac7c70539f72d 100644 (file)
@@ -105,7 +105,8 @@ func NewContent(
        if editor != "" {
                jww.FEEDBACK.Printf("Editing %s with %q ...\n", targetPath, editor)
 
-               cmd := exec.Command(editor, contentPath)
+               editorCmd := append(strings.Fields(editor), contentPath)
+               cmd := exec.Command(editorCmd[0], editorCmd[1:]...)
                cmd.Stdin = os.Stdin
                cmd.Stdout = os.Stdout
                cmd.Stderr = os.Stderr