Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-03-29 19:03:50 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-01 14:04:11 +0300
commitaf874cc63e75f9c3b6f6715727a3a3e92a3b686f (patch)
tree3f546a6986c8d2c646c7761bd7424c45aad4f99b
parentb1aa377a3f23e5e547cd142bb82a81b811c788a2 (diff)
grep: fix echo "aa" | busybox grep -F -w "a" (should not match)
function old new delta grep_file 1461 1470 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--findutils/grep.c2
-rwxr-xr-xtestsuite/grep.tests6
2 files changed, 7 insertions, 1 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index fc6de4b69..88de0d4ef 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -352,7 +352,7 @@ static int grep_file(FILE *file)
goto opt_f_not_found;
} else
if (option_mask32 & OPT_w) {
- char c = (match != str) ? match[-1] : ' ';
+ char c = (match != line) ? match[-1] : ' ';
if (!isalnum(c) && c != '_') {
c = match[strlen(gl->pattern)];
if (!c || (!isalnum(c) && c != '_'))
diff --git a/testsuite/grep.tests b/testsuite/grep.tests
index ed4ba455e..d0b0d2767 100755
--- a/testsuite/grep.tests
+++ b/testsuite/grep.tests
@@ -165,6 +165,12 @@ testing "grep -w word doesn't match wordword" \
"wordword\n" \
""
+testing "grep -F -w w doesn't match ww" \
+ "grep -F -w w input" \
+ "" \
+ "ww\n" \
+ ""
+
testing "grep -w word match second word" \
"grep -w word input" \
"bword,word\n""wordb,word\n""bwordb,word\n" \