From 858beaf143fbeb36e8b489994a3fed78141a54e1 Mon Sep 17 00:00:00 2001 From: Nicolas Martin Date: Mon, 26 Oct 2020 21:02:09 +0100 Subject: [PATCH] Check for $EDITOR before writing the file --- config_cmd.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config_cmd.go b/config_cmd.go index 800524f..122d982 100644 --- a/config_cmd.go +++ b/config_cmd.go @@ -27,6 +27,11 @@ var configCmd = &cobra.Command{ Example: formatBlock("glow config\nglow config --config path/to/config.yml"), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { + editor := os.Getenv("EDITOR") + if editor == "" { + return errors.New("no EDITOR environment variable set") + } + if configFile == "" { scope := gap.NewScope(gap.User, "glow") @@ -61,11 +66,6 @@ var configCmd = &cobra.Command{ return err } - editor := os.Getenv("EDITOR") - if editor == "" { - return errors.New("no EDITOR environment variable set") - } - c := exec.Command(editor, configFile) c.Stdin = os.Stdin c.Stdout = os.Stdout