From fa8a33c57ef8fb0d32e36289bbdbd8ce7cf18726 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 11 Jun 2017 12:23:00 -0500 Subject: Provide error messages for files we can open but not read (ala directories). --- toys/posix/grep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toys/posix/grep.c b/toys/posix/grep.c index c7b44e58..891f7600 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -102,7 +102,10 @@ static void do_grep(int fd, char *name) int mmatch = 0; lcount++; - if (0 > (len = getdelim(&line, &unused, TT.indelim, file))) break; + errno = 0; + len = getdelim(&line, &unused, TT.indelim, file); + if (errno) perror_msg("%s", name); + if (len<1) break; if (line[len-1] == TT.indelim) line[len-1] = 0; start = line; -- cgit v1.2.3