support EDITOR with spaces in the editor path (close #19, ref #10)

This commit is contained in:
itchyny 2023-04-09 12:29:16 +09:00
parent fec2c9b389
commit 467ba873c3

View file

@ -98,14 +98,7 @@ func rename(args []string) error {
}
defer tty.Close()
editor := os.Getenv("EDITOR")
if editor == "" {
editor = "vi"
}
editorWithArgs := strings.Fields(editor)
editorWithArgs = append(editorWithArgs, f.Name())
cmd := exec.Command(editorWithArgs[0], editorWithArgs[1:]...)
cmd := exec.Command("sh", "-c", `eval exec "${EDITOR:-vi}" '"$@"'`, "", f.Name())
cmd.Stdin = tty.Input()
cmd.Stdout = tty.Output()
cmd.Stderr = tty.Output()