From b18ea5ff7bfe07981ada9f7e2057f4fe490f3993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 3 Apr 2024 17:10:37 -0700 Subject: [PATCH] error if empty editor --- pkg/editor/editor.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/editor/editor.go b/pkg/editor/editor.go index 25edd19..ae9ff43 100644 --- a/pkg/editor/editor.go +++ b/pkg/editor/editor.go @@ -1,6 +1,7 @@ package editor import ( + "fmt" "io/fs" "os" "os/exec" @@ -18,6 +19,10 @@ type Editor struct { func (e *Editor) EditFile(filename string) error { args := append(e.Args, filename) + if e.Command == "" { + return fmt.Errorf("no editor set or detected") + } + cmd := exec.Command(e.Command, args...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout