Check for $EDITOR before writing the file

This commit is contained in:
Nicolas Martin 2020-10-26 21:02:09 +01:00
parent 4b4fb783d2
commit 858beaf143
No known key found for this signature in database
GPG key ID: 7B4E6623E5DCCC09

View file

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