aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-06-10 13:17:31 -0500
committerRob Landley <rob@landley.net>2017-06-10 13:17:31 -0500
commit24b1cc829fef3a2501ace6ac7e803e3642de45ad (patch)
treea9bedd1e2c9d733c0a1540ad666960e9be9c9b84
parent1f33eeb683e729681419c29ac831c6e71e6774fa (diff)
downloadtoybox-24b1cc829fef3a2501ace6ac7e803e3642de45ad.tar.gz
Fix bug where grep stopped at first dangling symlink and error_exited().
-rw-r--r--toys/posix/grep.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index a95203a0..c7b44e58 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -81,12 +81,18 @@ static void outline(char *line, char dash, char *name, long lcount, long bcount,
static void do_grep(int fd, char *name)
{
struct double_list *dlb = 0;
- FILE *file = xfdopen(fd, "r");
+ FILE *file = fdopen(fd, "r");
long lcount = 0, mcount = 0, offset = 0, after = 0, before = 0;
char *bars = 0;
if (!fd) name = "(standard input)";
+ if (!file) {
+ perror_msg("%s", name);
+
+ return;
+ }
+
// Loop through lines of input
for (;;) {
char *line = 0, *start;