From 42a8984abc5eed709addac263aab43d64d47257d Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Mon, 30 Mar 2020 11:02:08 +0200 Subject: grep: add proper support for pattern_list From POSIX.1-2008: The pattern_list's value shall consist of one or more patterns separated by characters; As such, given patterns need to be split at newline characters. Without doing so, busybox grep will interpret the newline as part of the pattern which is not in accordance with POSIX. See also: https://bugs.busybox.net/show_bug.cgi?id=12721 Signed-off-by: Denys Vlasenko --- testsuite/grep.tests | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'testsuite') diff --git a/testsuite/grep.tests b/testsuite/grep.tests index 9c1f35499..e38278810 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests @@ -190,6 +190,18 @@ testing "grep -x -v -e EXP1 -e EXP2 finds nothing if either EXP matches" \ "" \ " aa bb cc\n" +testing "grep PATTERN can be a newline-delimited list" \ + 'grep -Fv "$(printf "foo\nbar\n")"' \ + "baz\n" \ + "" \ + "foo\nbar\nbaz\n" + +testing "grep -e PATTERN can be a newline-delimited list" \ + 'grep -Fv -e "$(printf "foo\nbar\n")"' \ + "baz\n" \ + "" \ + "foo\nbar\nbaz\n" + # -r on symlink to dir should recurse into dir mkdir -p grep.testdir/foo echo bar > grep.testdir/foo/file -- cgit v1.2.3