aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-11-03 14:16:08 +0000
committerRon Yorston <rmy@pobox.com>2017-11-03 14:16:08 +0000
commitd6ce08aeb85b3698ddaa281016b70e16aeb9fb35 (patch)
tree02ad9bc0684859515fe891f3d6b0a1086e0db156 /findutils
parentab450021a99ba66126cc6d668fb06ec3829a572b (diff)
parenta5060b8364faa7c677c8950f1315c451403b0660 (diff)
downloadbusybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.gz
busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.bz2
busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'findutils')
-rw-r--r--findutils/grep.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index f72175afb..fc6de4b69 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -639,11 +639,28 @@ static void load_regexes_from_file(llist_t *fopt)
639} 639}
640 640
641static int FAST_FUNC file_action_grep(const char *filename, 641static int FAST_FUNC file_action_grep(const char *filename,
642 struct stat *statbuf UNUSED_PARAM, 642 struct stat *statbuf,
643 void* matched, 643 void* matched,
644 int depth UNUSED_PARAM) 644 int depth UNUSED_PARAM)
645{ 645{
646 FILE *file = fopen_for_read(filename); 646 FILE *file;
647
648 /* If we are given a link to a directory, we should bail out now, rather
649 * than trying to open the "file" and hoping getline gives us nothing,
650 * since that is not portable across operating systems (FreeBSD for
651 * example will return the raw directory contents). */
652 if (S_ISLNK(statbuf->st_mode)) {
653 struct stat sb;
654 if (stat(filename, &sb) != 0) {
655 if (!SUPPRESS_ERR_MSGS)
656 bb_simple_perror_msg(filename);
657 return 0;
658 }
659 if (S_ISDIR(sb.st_mode))
660 return 1;
661 }
662
663 file = fopen_for_read(filename);
647 if (file == NULL) { 664 if (file == NULL) {
648 if (!SUPPRESS_ERR_MSGS) 665 if (!SUPPRESS_ERR_MSGS)
649 bb_simple_perror_msg(filename); 666 bb_simple_perror_msg(filename);