diff --git a/src/cli/edit.go b/src/cli/edit.go index f03227cc..eb2c1a39 100644 --- a/src/cli/edit.go +++ b/src/cli/edit.go @@ -14,21 +14,22 @@ func editFileWithEditor(file string) int { return 1 } - var args []string - if strings.Contains(editor, " ") { - strs := strings.Split(editor, " ") - editor = strs[0] - args = strs[1:] - } + editor = strings.TrimSpace(editor) + args := strings.Split(editor, " ") + + editor = args[0] + args = append(args[1:], file) - args = append(args, file) cmd := exec.Command(editor, args...) - err := cmd.Run() - if err != nil { + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { fmt.Println(err.Error()) return 1 } - return cmd.ProcessState.ExitCode() + return 0 }