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
}
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
}