aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-08-28 15:50:09 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-08-28 15:50:09 +0200
commit34cc6c91a286411a8275d9d61aa80397fe1e5fa3 (patch)
tree2808db0f61e5e63dc390330c98ce5acd7cefea9a
parent6ff055115798166e172039284448be758b04e195 (diff)
downloadbusybox-w32-34cc6c91a286411a8275d9d61aa80397fe1e5fa3.tar.gz
busybox-w32-34cc6c91a286411a8275d9d61aa80397fe1e5fa3.tar.bz2
busybox-w32-34cc6c91a286411a8275d9d61aa80397fe1e5fa3.zip
grep: fix "grep -r PATTRN SYMLINK_TO_DIR"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--findutils/grep.c2
-rwxr-xr-xtestsuite/grep.tests20
2 files changed, 21 insertions, 1 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index f1b6dc694..b9621384e 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -668,7 +668,7 @@ static int grep_dir(const char *dir)
668 int matched = 0; 668 int matched = 0;
669 recursive_action(dir, 669 recursive_action(dir,
670 /* recurse=yes */ ACTION_RECURSE | 670 /* recurse=yes */ ACTION_RECURSE |
671 /* followLinks=no */ 671 /* followLinks=command line only */ ACTION_FOLLOWLINKS_L0 |
672 /* depthFirst=yes */ ACTION_DEPTHFIRST, 672 /* depthFirst=yes */ ACTION_DEPTHFIRST,
673 /* fileAction= */ file_action_grep, 673 /* fileAction= */ file_action_grep,
674 /* dirAction= */ NULL, 674 /* dirAction= */ NULL,
diff --git a/testsuite/grep.tests b/testsuite/grep.tests
index 323b3849d..f6d9f2105 100755
--- a/testsuite/grep.tests
+++ b/testsuite/grep.tests
@@ -171,6 +171,26 @@ testing "grep -w word match second word" \
171 "bword,word\n""wordb,word\n""bwordb,word\n" \ 171 "bword,word\n""wordb,word\n""bwordb,word\n" \
172 "" 172 ""
173 173
174# -r on symlink to dir should recurse into dir
175mkdir -p grep.testdir/foo
176echo bar > grep.testdir/foo/file
177ln -s foo grep.testdir/symfoo
178testing "grep -r on symlink to dir" \
179 "grep -r . grep.testdir/symfoo" \
180 "grep.testdir/symfoo/file:bar\n" \
181 "" ""
182rm -Rf grep.testdir
183
184# But -r on dir/symlink_to_dir should not recurse into symlink_to_dir
185mkdir -p grep.testdir/foo
186echo bar > grep.testdir/foo/file
187ln -s foo grep.testdir/symfoo
188testing "grep -r on dir/symlink to dir" \
189 "grep -r . grep.testdir" \
190 "grep.testdir/foo/file:bar\n" \
191 "" ""
192rm -Rf grep.testdir
193
174# testing "test name" "commands" "expected result" "file input" "stdin" 194# testing "test name" "commands" "expected result" "file input" "stdin"
175# file input will be file called "input" 195# file input will be file called "input"
176# test can create a file "actual" instead of writing to stdout 196# test can create a file "actual" instead of writing to stdout