From bba8c040c263a3255c82aa232e5a93fd6683a7ec Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Fri, 20 Dec 2024 09:05:48 +0100 Subject: [PATCH] fix(cli): open EDITOR correctly resolves #6019 --- src/cli/edit.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) 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 }