aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/posix/grep.c5
1 files changed, 4 insertions, 1 deletions
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;