OSDN Git Service

Provide error messages for files we can open but not read (ala directories).
authorRob Landley <rob@landley.net>
Sun, 11 Jun 2017 17:23:00 +0000 (12:23 -0500)
committerRob Landley <rob@landley.net>
Sun, 11 Jun 2017 17:23:00 +0000 (12:23 -0500)
toys/posix/grep.c

index c7b44e5..891f760 100644 (file)
@@ -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;