From 467ba873c33a125f497b78adc414f9c8b21ed0ed Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 9 Apr 2023 12:29:16 +0900 Subject: [PATCH] support EDITOR with spaces in the editor path (close #19, ref #10) --- cmd/mmv/main.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/mmv/main.go b/cmd/mmv/main.go index e560186..01a80a7 100644 --- a/cmd/mmv/main.go +++ b/cmd/mmv/main.go @@ -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()