From 3f01f73ea96fa5b4540aa656a7d4958dc743be69 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 7 Dec 2016 10:28:03 -0500 Subject: [PATCH] Give error message if input is a directory Fixes #479 --- cmd/micro/micro.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index ab654481..33cf2a20 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -97,11 +97,16 @@ func LoadInput() []*Buffer { if _, e := os.Stat(filename); e == nil { // If it exists we load it into a buffer input, err = os.Open(filename) + stat, _ := input.Stat() defer input.Close() if err != nil { TermMessage(err) continue } + if stat.IsDir() { + TermMessage("Cannot read", filename, "because it is a directory") + continue + } } // If the file didn't exist, input will be empty, and we'll open an empty buffer if input != nil {