fix(cli): open EDITOR correctly
Some checks failed
Code QL / code-ql (push) Has been cancelled
Release / changelog (push) Has been cancelled
Release / artifacts (push) Has been cancelled
Release / msi (arm64) (push) Has been cancelled
Release / msi (x64) (push) Has been cancelled
Release / msi (x86) (push) Has been cancelled
Release / release (push) Has been cancelled

resolves #6019
This commit is contained in:
Jan De Dobbeleer 2024-12-20 09:05:48 +01:00 committed by Jan De Dobbeleer
parent b4d0b42395
commit bba8c040c2

View file

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